diff sqlex/model.py @ 3:5f1e1ac96aa7

stub works with SELECT
author Jeff Hammel <k0scist@gmail.com>
date Sat, 01 Apr 2017 09:19:22 -0700
parents 63a75d318b06
children 3a7f515571dc
line wrap: on
line diff
--- a/sqlex/model.py	Sat Apr 01 08:44:42 2017 -0700
+++ b/sqlex/model.py	Sat Apr 01 09:19:22 2017 -0700
@@ -11,9 +11,13 @@
         self.conn = sqlite3.connect(self.db)
 
     def __call__(self, sql, *args):
-        c = conn.cursor()
+        c = self.conn.cursor()
         c.execute(sql, args)
-        c.commit()
+        self.conn.commit()
+        try:
+            return c.fetchall()
+        except Exception as e:
+            raise e
 
     def __del__(self):
         self.conn.close()
@@ -24,7 +28,6 @@
         """
         # http://stackoverflow.com/questions/82875/how-to-list-the-tables-in-an-sqlite-database-file-that-was-opened-with-attach
 
-        sql = "SELECT name FROM dbname.sqlite_master WHERE type='table';"
+        sql = "SELECT name FROM sqlite_master WHERE type='table';"
         tables = self(sql)
-        return tables
-
+        return sum([list(item) for item in tables], [])