diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sqlitex/api.py	Tue Mar 15 11:29:22 2016 -0700
@@ -0,0 +1,37 @@
+"""
+sqlitex API
+"""
+
+# imports
+import argparse
+import csv
+import os
+import sqlite3
+import sys
+
+
+class SQLitEx(object):
+
+    def __init__(self, db_file):
+        self.db_file = os.path.abspath(db_file)
+        if not os.path.isfile(self.db_file):
+            raise AssertionError("Not a file: '{0}'".format(self.db_file))
+
+
+def main(args=sys.argv[1:]):
+    """CLI"""
+
+    # parse command line
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument('db_file',
+                        help="path to sqlite database file")
+    parser.add_argument('table', nargs='?', default=None,
+                        help="table to output")
+
+    options = parser.parse_args(args)
+
+    # instantiate api
+    api = SQLitEx(options.db_file)
+
+if __name__ == '__main__':
+    main()