Mercurial > repos > jjohnson > query_tabular
comparison sqlite_to_tabular.py @ 22:bed5018e7ae3 draft
Uploaded
author | jjohnson |
---|---|
date | Mon, 17 Jul 2017 15:22:04 -0400 |
parents | ab27c4bd14b9 |
children |
comparison
equal
deleted
inserted
replaced
21:357fe86f245d | 22:bed5018e7ae3 |
---|---|
29 if options.output is not None: | 29 if options.output is not None: |
30 try: | 30 try: |
31 outputPath = os.path.abspath(options.output) | 31 outputPath = os.path.abspath(options.output) |
32 outputFile = open(outputPath, 'w') | 32 outputFile = open(outputPath, 'w') |
33 except Exception as e: | 33 except Exception as e: |
34 print("failed: %s" % e, file=sys.stderr) | 34 exit('Error: %s' % (e)) |
35 exit(3) | |
36 else: | 35 else: |
37 outputFile = sys.stdout | 36 outputFile = sys.stdout |
38 | 37 |
39 query = None | 38 query = None |
40 if (options.query_file is not None): | 39 if (options.query_file is not None): |
46 query = options.query | 45 query = options.query |
47 | 46 |
48 if (query is None): | 47 if (query is None): |
49 try: | 48 try: |
50 describe_tables(get_connection(options.sqlitedb), outputFile) | 49 describe_tables(get_connection(options.sqlitedb), outputFile) |
51 except Exception as exc: | 50 except Exception as e: |
52 print("Error: %s" % exc, file=sys.stderr) | 51 exit('Error: %s' % (e)) |
53 exit(0) | 52 exit(0) |
54 else: | 53 else: |
55 try: | 54 try: |
56 run_query(get_connection(options.sqlitedb), query, outputFile, | 55 run_query(get_connection(options.sqlitedb), query, outputFile, |
57 no_header=options.no_header) | 56 no_header=options.no_header) |
58 except Exception as exc: | 57 except Exception as e: |
59 print("Error: %s" % exc, file=sys.stderr) | 58 exit('Error: %s' % (e)) |
60 exit(1) | |
61 | 59 |
62 | 60 |
63 if __name__ == "__main__": | 61 if __name__ == "__main__": |
64 __main__() | 62 __main__() |