@@ -24,25 +24,32 @@ def cli():
2424)
2525@click .argument ("tables" , nargs = - 1 , required = False )
2626@click .option ("--all" , is_flag = True , help = "Dump all tables" )
27- def dump (dbpath , output , tables , all ):
27+ @click .option ("--exclude" , multiple = True , help = "Tables to exclude from the dump" )
28+ def dump (dbpath , output , tables , all , exclude ):
2829 """
2930 Dump a SQLite database out as flat files in the directory
3031
3132 Usage:
3233
3334 sqlite-diffable dump my.db output/ --all
3435
35- --all dumps ever table. Or specify tables like this:
36+ --all dumps every table. Or specify tables like this:
3637
3738 sqlite-diffable dump my.db output/ entries tags
39+
40+ Exclude specific tables:
41+
42+ sqlite-diffable dump my.db output/ --all --exclude table1 --exclude table2
3843 """
3944 if not tables and not all :
4045 raise click .ClickException ("You must pass --all or specify some tables" )
4146 output = pathlib .Path (output )
4247 output .mkdir (exist_ok = True )
4348 conn = sqlite_utils .Database (dbpath )
4449 if all :
45- tables = conn .table_names ()
50+ tables = set (conn .table_names ()) - set (exclude )
51+ else :
52+ tables = set (tables ) - set (exclude )
4653 for table in tables :
4754 tablename = table .replace ("/" , "" )
4855 filepath = output / "{}.ndjson" .format (tablename )
0 commit comments