3 dbFile = 'sqLibrary.db'
6 bookTableCreation = '''
7 CREATE TABLE IF NOT EXISTS books
8 (id INTEGER PRIMARY KEY,
9 isbn, lccn, title, subtitle, authors, edition,
10 publisher, publish_year, publish_month, publish_location,
11 pages, pagination, weight)
15 return s.replace(" ","_").lower()
17 # escapes strings and such
19 return '"' + str(v).strip().replace('"','""') + '"'
22 conn = sqlite3.connect(dbFile)
26 for k,v in book.items():
28 cols.append(colify(k))
29 vals.append(stringify(v))
31 query = "INSERT INTO "+bookTable+" ("+", ".join(cols)+") VALUES ("+", ".join(vals)+");"
36 def createBooksTable():
37 conn = sqlite3.connect(dbFile)
39 c.execute(bookTableCreation)