@@ -18,18 +18,24 @@ def cli():
1818@click .argument (
1919 "output" , type = click .Path (file_okay = False , dir_okay = True ), required = True
2020)
21- @click .argument ("tables" , nargs = - 1 , required = True )
22- def dump (path , output , tables ):
21+ @click .argument ("tables" , nargs = - 1 , required = False )
22+ @click .option ("--all" , is_flag = True )
23+ def dump (path , output , tables , all ):
24+ if not tables and not all :
25+ raise click .ClickException ("You must pass --all or specify some tables" )
2326 output = pathlib .Path (output )
2427 output .mkdir (exist_ok = True )
2528 conn = sqlite_utils .Database (path )
29+ if all :
30+ tables = conn .table_names ()
2631 for table in tables :
27- filepath = output / "{}.ndjson" .format (table )
28- metapath = output / "{}.metadata.json" .format (table )
32+ tablename = table .replace ("/" , "" )
33+ filepath = output / "{}.ndjson" .format (tablename )
34+ metapath = output / "{}.metadata.json" .format (tablename )
2935 # Dump rows to filepath
3036 with filepath .open ("w" ) as fp :
3137 for row in conn [table ].rows :
32- fp .write (json .dumps (list (row .values ())) + "\n " )
38+ fp .write (json .dumps (list (row .values ()), default = repr ) + "\n " )
3339 fp .close ()
3440 # Dump out metadata
3541 metapath .open ("w" ).write (
0 commit comments