Mercurial > repos > iuc > sqlite_to_tabular
comparison query_db.py @ 1:89d898454f1e 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:47:20 -0400 |
| parents | c866ec050312 |
| children | 5600704453b8 |
comparison
equal
deleted
inserted
replaced
| 0:c866ec050312 | 1:89d898454f1e |
|---|---|
| 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])) |
