comparison sqlitex/api.py @ 0:4b51bcbcdb15

initial stub
author Jeff Hammel <k0scist@gmail.com>
date Tue, 15 Mar 2016 11:29:22 -0700
parents
children 7f92e207830b
comparison
equal deleted inserted replaced
-1:000000000000 0:4b51bcbcdb15
1 """
2 sqlitex API
3 """
4
5 # imports
6 import argparse
7 import csv
8 import os
9 import sqlite3
10 import sys
11
12
13 class SQLitEx(object):
14
15 def __init__(self, db_file):
16 self.db_file = os.path.abspath(db_file)
17 if not os.path.isfile(self.db_file):
18 raise AssertionError("Not a file: '{0}'".format(self.db_file))
19
20
21 def main(args=sys.argv[1:]):
22 """CLI"""
23
24 # parse command line
25 parser = argparse.ArgumentParser(description=__doc__)
26 parser.add_argument('db_file',
27 help="path to sqlite database file")
28 parser.add_argument('table', nargs='?', default=None,
29 help="table to output")
30
31 options = parser.parse_args(args)
32
33 # instantiate api
34 api = SQLitEx(options.db_file)
35
36 if __name__ == '__main__':
37 main()