Mercurial > hg > sqlex
comparison sqlex/main.py @ 8:adf056d67c01
ability to export entire db to directory
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sat, 01 Apr 2017 13:01:57 -0700 |
parents | 22fbe50d92e8 |
children | 834b920ae345 |
comparison
equal
deleted
inserted
replaced
7:7d6acedf1a67 | 8:adf056d67c01 |
---|---|
106 else: | 106 else: |
107 db.table2csv(options.table, sys.stdout) | 107 db.table2csv(options.table, sys.stdout) |
108 sys.stdout.flush() | 108 sys.stdout.flush() |
109 else: | 109 else: |
110 # output entire db to CSV files in directory | 110 # output entire db to CSV files in directory |
111 raise NotImplementedError('TODO') | 111 |
112 # ensure directory exists | |
113 ensure_dir(options.output) | |
114 | |
115 for table in db.tables(): | |
116 # export each table | |
117 path = os.path.join(options.output, '{}.csv'.format(table)) | |
118 with open(path, 'w') as f: | |
119 db.table2csv(table, f) | |
120 | |
112 | 121 |
113 if __name__ == '__main__': | 122 if __name__ == '__main__': |
114 main() | 123 main() |