batchquery.py
changeset 101 2a2d0d5df03b
parent 93 b72591087495
child 104 d8ff52a0390f
equal deleted inserted replaced
100:d6088dba8fea 101:2a2d0d5df03b
    10         self.parser.add_argument('--file', dest='file', type=str, help='CSV file with data to use as arguments.')
    10         self.parser.add_argument('--file', dest='file', type=str, help='CSV file with data to use as arguments.')
    11         self.parser.add_argument('--init', dest='init', type=str, help='Query which initialize database session (eg. temporary function).')
    11         self.parser.add_argument('--init', dest='init', type=str, help='Query which initialize database session (eg. temporary function).')
    12         self.parser.add_argument('--output', dest='output', type=str, help='File name for results.')
    12         self.parser.add_argument('--output', dest='output', type=str, help='File name for results.')
    13         self.parser.add_argument('--outputfunc', dest='outputfunc', type=str, help='Python function which will format results (format_row(args, rows)).')
    13         self.parser.add_argument('--outputfunc', dest='outputfunc', type=str, help='Python function which will format results (format_row(args, rows)).')
    14         self.parser.add_argument('--header', dest='header', action='store_true', help='First line of CSV is header with names for columns. These name can be used in query.')
    14         self.parser.add_argument('--header', dest='header', action='store_true', help='First line of CSV is header with names for columns. These name can be used in query.')
    15         self.init()
       
    16 
    15 
    17     def _split_line(self, line):
    16     def _split_line(self, line):
    18         return [x.strip() for x in line.split(',')]
    17         return [x.strip() for x in line.split(',')]
    19 
    18 
    20     def main(self):
    19     def main(self):
    63                         f.write(repr(rows))
    62                         f.write(repr(rows))
    64                     f.write('\n')
    63                     f.write('\n')
    65 
    64 
    66 
    65 
    67 tool = BatchQueryTool()
    66 tool = BatchQueryTool()
       
    67 tool.setup()
    68 tool.main()
    68 tool.main()
    69 
    69