comparison query_db.py @ 4:fe7be5634ab3 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:17:06 -0400
parents cd2a99849f8b
children 69b08fc9557c
comparison
equal deleted inserted replaced
3:98b40ecad32b 4:fe7be5634ab3
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