comparison query_tabular.py @ 1:8a33b442ecd9 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:09 -0400
parents 3708ff0198b7
children 1ea4e668bf73
comparison
equal deleted inserted replaced
0:3708ff0198b7 1:8a33b442ecd9
54 parser.add_option('-Q', '--query_file', dest='query_file', default=None, 54 parser.add_option('-Q', '--query_file', dest='query_file', default=None,
55 help='SQL query file') 55 help='SQL query file')
56 parser.add_option('-n', '--no_header', dest='no_header', default=False, 56 parser.add_option('-n', '--no_header', dest='no_header', default=False,
57 action='store_true', 57 action='store_true',
58 help='Include a column headers line') 58 help='Include a column headers line')
59 parser.add_option('-c', '--comment_char', dest='comment_char', default='',
60 help='comment character to prefix column header line')
59 parser.add_option('-o', '--output', dest='output', default=None, 61 parser.add_option('-o', '--output', dest='output', default=None,
60 help='Output file for query results') 62 help='Output file for query results')
61 (options, args) = parser.parse_args() 63 (options, args) = parser.parse_args()
62 64
63 # determine output destination 65 # determine output destination
78 table['comment_lines'] if 'comment_lines' in table else 0 80 table['comment_lines'] if 'comment_lines' in table else 0
79 comment_char =\ 81 comment_char =\
80 table['comment_char'] if 'comment_char' in table else None 82 table['comment_char'] if 'comment_char' in table else None
81 column_names =\ 83 column_names =\
82 table['column_names'] if 'column_names' in table else None 84 table['column_names'] if 'column_names' in table else None
85 firstlinenames =\
86 table['firstlinenames'] if 'firstlinenames' in table else False
83 if column_names: 87 if column_names:
84 load_named_columns =\ 88 load_named_columns =\
85 table['load_named_columns']\ 89 table['load_named_columns']\
86 if 'load_named_columns' in table else False 90 if 'load_named_columns' in table else False
87 else: 91 else:
91 filters = table['filters'] if 'filters' in table else None 95 filters = table['filters'] if 'filters' in table else None
92 pkey_autoincr = \ 96 pkey_autoincr = \
93 table['pkey_autoincr'] if 'pkey_autoincr' in table else None 97 table['pkey_autoincr'] if 'pkey_autoincr' in table else None
94 create_table(get_connection(options.sqlitedb), path, table_name, 98 create_table(get_connection(options.sqlitedb), path, table_name,
95 pkey_autoincr=pkey_autoincr, 99 pkey_autoincr=pkey_autoincr,
100 firstlinenames=firstlinenames,
96 column_names=column_names, 101 column_names=column_names,
97 skip=comment_lines, 102 skip=comment_lines,
98 comment_char=comment_char, 103 comment_char=comment_char,
99 load_named_columns=load_named_columns, 104 load_named_columns=load_named_columns,
100 filters=filters, 105 filters=filters,
126 except Exception as e: 131 except Exception as e:
127 exit('Error: %s' % (e)) 132 exit('Error: %s' % (e))
128 else: 133 else:
129 try: 134 try:
130 run_query(get_connection(options.sqlitedb), query, outputFile, 135 run_query(get_connection(options.sqlitedb), query, outputFile,
131 no_header=options.no_header) 136 no_header=options.no_header,
137 comment_char=options.comment_char)
132 except Exception as e: 138 except Exception as e:
133 exit('Error: %s' % (e)) 139 exit('Error: %s' % (e))
134 140
135 141
136 if __name__ == "__main__": 142 if __name__ == "__main__":