comparison query_db.py @ 1:c1b700bc0150 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit 81f69ad5f39223059c40501e55ac777d3feca845
author iuc
date Fri, 18 Aug 2017 16:48:20 -0400
parents 859064f07be4
children 6e72fd26a9d3
comparison
equal deleted inserted replaced
0:859064f07be4 1:c1b700bc0150
54 except Exception as e: 54 except Exception as e:
55 exit('Error: %s' % (e)) 55 exit('Error: %s' % (e))
56 exit(0) 56 exit(0)
57 57
58 58
59 def run_query(conn, query, outputFile, no_header=False): 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 not no_header:
63 outputFile.write("#%s\n" % '\t'.join( 63 outputFile.write("%s%s\n" % (comment_char, '\t'.join(
64 [str(col[0]) for col in cur.description])) 64 [str(col[0]) for col in cur.description])))
65 for i, row in enumerate(results): 65 for i, row in enumerate(results):
66 outputFile.write("%s\n" % '\t'.join( 66 outputFile.write("%s\n" % '\t'.join(
67 [str(val) if val is not None else '' for val in row])) 67 [str(val) if val is not None else '' for val in row]))