# HG changeset patch # User Jeff Hammel # Date 1491076917 25200 # Node ID adf056d67c014a19c6aac44aa9d23b11308b8d0c # Parent 7d6acedf1a67915501e939f3eca17da0db63c3a9 ability to export entire db to directory diff -r 7d6acedf1a67 -r adf056d67c01 sqlex/main.py --- a/sqlex/main.py Sat Apr 01 12:37:38 2017 -0700 +++ b/sqlex/main.py Sat Apr 01 13:01:57 2017 -0700 @@ -108,7 +108,16 @@ sys.stdout.flush() else: # output entire db to CSV files in directory - raise NotImplementedError('TODO') + + # ensure directory exists + ensure_dir(options.output) + + for table in db.tables(): + # export each table + path = os.path.join(options.output, '{}.csv'.format(table)) + with open(path, 'w') as f: + db.table2csv(table, f) + if __name__ == '__main__': main()