feat: add Database.merge() and sqlite-utils merge command#724
Open
abhiyadav2345 wants to merge 1 commit intosimonw:mainfrom
Open
feat: add Database.merge() and sqlite-utils merge command#724abhiyadav2345 wants to merge 1 commit intosimonw:mainfrom
abhiyadav2345 wants to merge 1 commit intosimonw:mainfrom
Conversation
Implements the ability to merge tables from one or more source SQLite databases into a destination database, as requested in simonw#491. Python API: db.merge([src1, src2], alter=True, replace=False, ignore=False, tables=None) - source_dbs can be Database objects or file paths - Tables not in dest are created; existing tables have rows inserted - alter=True adds missing columns to existing destination tables - replace=True overwrites rows with matching primary keys - ignore=True skips rows with conflicting primary keys - tables= limits which tables are merged - Virtual tables and their shadow tables are automatically skipped CLI: sqlite-utils merge combined.db one.db two.db [options] - Supports --alter, --replace, --ignore, --pk, --table, --load-extension Closes simonw#491
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #491.
Adds the ability to merge tables from one or more source SQLite databases into a destination database.
Python API
CLI
Implementation notes
--replaceor--ignore)--pkoverrides thisdocs_fts_data) are also skipped via parent name detectionmerge()returnsselffor chainingTests
17 new tests covering the Python API and CLI — all passing, no regressions in existing 1042 tests.
Docs
Added a
Merging databasessection todocs/cli.rstwith examples for all options.📚 Documentation preview 📚: https://sqlite-utils--724.org.readthedocs.build/en/724/