Mercurial > repos > iuc > query_tabular
diff query_db.py @ 4:973f03d82c86 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit 6a362345c31764c28bb6328da1f0d81ef8f35d40
author | iuc |
---|---|
date | Thu, 03 May 2018 10:16:38 -0400 |
parents | 8a33b442ecd9 |
children | a3aab6045663 |
line wrap: on
line diff
--- a/query_db.py Mon Nov 06 23:20:29 2017 -0500 +++ b/query_db.py Thu May 03 10:16:38 2018 -0400 @@ -59,9 +59,13 @@ def run_query(conn, query, outputFile, no_header=False, comment_char='#'): cur = conn.cursor() results = cur.execute(query) - if not no_header: - outputFile.write("%s%s\n" % (comment_char, '\t'.join( - [str(col[0]) for col in cur.description]))) - for i, row in enumerate(results): - outputFile.write("%s\n" % '\t'.join( - [str(val) if val is not None else '' for val in row])) + if outputFile is not None: + if not no_header: + outputFile.write("%s%s\n" % (comment_char, '\t'.join( + [str(col[0]) for col in cur.description]))) + for i, row in enumerate(results): + outputFile.write("%s\n" % '\t'.join( + [str(val) if val is not None else '' for val in row])) + else: + conn.commit() + return results