simonw/sqlite-utils

Ability to merge databases and tables

Open

#491 opened on Sep 23, 2022

 (9 comments) (3 reactions) (0 assignees)Python (145 forks)github user discovery
cli-toolhelp wanted

Repository metrics

Stars
 (2,065 stars)
PR merge metrics
 (Avg merge 9h 52m) (7 merged PRs in 30d)

Description

Hi! Let me firstly say that I am a big fan of your work -- I follow your tweets and blog posts with great interest 😄.

Now onto the matter at hand: I think it would be great if sqlite-utils included a merge or combine command, with the purpose of combining different SQLite databases into a single SQLite database. This way, the newly "merged" database would contain all differently named tables contained in the databases to be merged as-is, as well a concatenation of all tables of the same name.

This could look something like this:

sqlite-utils merge cats.db dogs.db > animals.db

I imagine this is rather straightforward if all databases involved in the merge contain differently named tables (i.e. no chance of conflicts), but things get slightly more complicated if two or more of the databases to be merged contain tables with the same name. Not only do you have to "do something" with the primary key(s), but these tables could also simply have different schemas (and therefore be incompatible for concatenation to begin with).

Anyhow, I would love your thoughts on this, and, if you are open to it, work together on the design and implementation!

Contributor guide