comparison 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
comparison
equal deleted inserted replaced
3:1ea4e668bf73 4:973f03d82c86
57 57
58 58
59 def run_query(conn, query, outputFile, no_header=False, comment_char='#'): 59 def run_query(conn, query, outputFile, no_header=False, comment_char='#'):
60 cur = conn.cursor() 60 cur = conn.cursor()
61 results = cur.execute(query) 61 results = cur.execute(query)
62 if not no_header: 62 if outputFile is not None:
63 outputFile.write("%s%s\n" % (comment_char, '\t'.join( 63 if not no_header:
64 [str(col[0]) for col in cur.description]))) 64 outputFile.write("%s%s\n" % (comment_char, '\t'.join(
65 for i, row in enumerate(results): 65 [str(col[0]) for col in cur.description])))
66 outputFile.write("%s\n" % '\t'.join( 66 for i, row in enumerate(results):
67 [str(val) if val is not None else '' for val in row])) 67 outputFile.write("%s\n" % '\t'.join(
68 [str(val) if val is not None else '' for val in row]))
69 else:
70 conn.commit()
71 return results