changeset 1:1cfdb859f9d2

skeleton
author Jeff Hammel <k0scist@gmail.com>
date Fri, 31 Mar 2017 20:31:31 -0700
parents a05c70cc24be
children 63a75d318b06
files sqlex/main.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sqlex/main.py	Fri Mar 31 18:21:15 2017 -0700
+++ b/sqlex/main.py	Fri Mar 31 20:31:31 2017 -0700
@@ -8,6 +8,7 @@
 # imports
 import argparse
 import os
+import sqlite3
 import sys
 
 def ensure_dir(directory):
@@ -27,7 +28,9 @@
         kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter)
         kwargs.setdefault('description', __doc__)
         argparse.ArgumentParser.__init__(self, **kwargs)
-        self.add_argument('db', help="sqlite `.db` file")
+        self.add_argument('db',
+                          help="sqlite `.db` file")
+        self.add_argument(
         self.options = None
 
     def parse_args(self, *args, **kw):
@@ -39,6 +42,11 @@
     def validate(self, options):
         """validate options"""
 
+        try:
+            open(options.db)
+        except Exception as e:
+            self.error("Could not open '{}': {}".format(options.db, e))
+
 def main(args=sys.argv[1:]):
     """CLI"""