Add an --exclude option to the dump command #11
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.
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 complexityNote2: 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
--exclude
s or even implementing it as an opt-out regex, but ultimately decided against the unnecessary additional complexity.Happy to hear any feedback