Better name for db module
authorJohn Ladan <jladan@uwaterloo.ca>
Mon, 19 Mar 2012 18:06:17 +0000 (14:06 -0400)
committerJohn Ladan <jladan@uwaterloo.ca>
Mon, 19 Mar 2012 18:06:17 +0000 (14:06 -0400)
dbLayer.py [new file with mode: 0644]
librarian.py
sqCatalogue.py [deleted file]

diff --git a/dbLayer.py b/dbLayer.py
new file mode 100644 (file)
index 0000000..50687e1
--- /dev/null
@@ -0,0 +1,43 @@
+import sqlite3
+
+dbFile = 'sqLibrary.db'
+bookTable = 'books'
+
+bookTableCreation = '''
+CREATE TABLE IF NOT EXISTS books
+    (id INTEGER PRIMARY KEY, 
+     isbn, lccn, title, subtitle, authors, edition, 
+     publisher, publish_year, publish_month, publish_location, 
+     pages, pagination, weight)
+'''
+
+def colify(s):
+    return s.replace(" ","_").lower()
+
+# escapes strings and such
+def stringify(v):
+    return '"' + str(v).strip().replace('"','""') + '"'
+
+def addBook(book):
+    conn = sqlite3.connect(dbFile)
+    c = conn.cursor()
+    cols = []
+    vals = []
+    for k,v in book.items():
+        if v!="":
+            cols.append(colify(k))
+            vals.append(stringify(v))
+    
+    query = "INSERT INTO "+bookTable+" ("+", ".join(cols)+") VALUES ("+", ".join(vals)+");"
+    c.execute(query)
+    conn.commit()
+    c.close()
+
+def createBooksTable():
+    conn = sqlite3.connect(dbFile)
+    c = conn.cursor()
+    c.execute(bookTableCreation)
+    conn.commit()
+    c.close()
+
+createBooksTable()
index 82da6f1..69ffede 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 import curses
 #!/usr/bin/env python
 
 import curses
-import sqCatalogue as db
+import dbLayer as db
 
 stdscr=0
 
 
 stdscr=0
 
diff --git a/sqCatalogue.py b/sqCatalogue.py
deleted file mode 100644 (file)
index 50687e1..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-import sqlite3
-
-dbFile = 'sqLibrary.db'
-bookTable = 'books'
-
-bookTableCreation = '''
-CREATE TABLE IF NOT EXISTS books
-    (id INTEGER PRIMARY KEY, 
-     isbn, lccn, title, subtitle, authors, edition, 
-     publisher, publish_year, publish_month, publish_location, 
-     pages, pagination, weight)
-'''
-
-def colify(s):
-    return s.replace(" ","_").lower()
-
-# escapes strings and such
-def stringify(v):
-    return '"' + str(v).strip().replace('"','""') + '"'
-
-def addBook(book):
-    conn = sqlite3.connect(dbFile)
-    c = conn.cursor()
-    cols = []
-    vals = []
-    for k,v in book.items():
-        if v!="":
-            cols.append(colify(k))
-            vals.append(stringify(v))
-    
-    query = "INSERT INTO "+bookTable+" ("+", ".join(cols)+") VALUES ("+", ".join(vals)+");"
-    c.execute(query)
-    conn.commit()
-    c.close()
-
-def createBooksTable():
-    conn = sqlite3.connect(dbFile)
-    c = conn.cursor()
-    c.execute(bookTableCreation)
-    conn.commit()
-    c.close()
-
-createBooksTable()