Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an --exclude option to the dump command #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

giuli007
Copy link

@giuli007 giuli007 commented Dec 18, 2024

First of all thanks for this tool!

I find myself wanting to dump all tables in a database with the exclusions of a few.
For the curious about more details I would like to dump all the tables of a database with the exclusion of the tables automatically created by the FTS module https://www.sqlite.org/fts5.html#fts5_data_structures (%_idx, %_data, etc tables); if I don't exclude these tables when making a full dump of a database, it would then error on re-load because these tables are automatically created. The specific use-case I tried this on was with the logs database used by https://github.com/simonw/llm, see simonw/llm#680 for more details.

It is already possible to explicit only dump some tables by listing their names.
However as databases evolve, rather than having to keep track of new tables to add to the list of those to export, I think it would be convenient to just request a dump of all tables minus a few unwanted ones.

This PR introduces the --exclude parameter that can be used to exclude specific tables.

Note: The same can be achieved with a combination of sqlite-utils invocations to list all tables and remove the unwanted ones, but I think directly adding the --exclude parameter helps with the ergonomics of this tool for minimal added complexity
Note2: I thought about implementing a more flexible logic for the new parameter, for example by providing a single comma-separated value instead of having to use multiple --excludes or even implementing it as an opt-out regex, but ultimately decided against the unnecessary additional complexity.

Happy to hear any feedback

to allow excluding specific tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant