+import sys
import sqlite3
dbFile = 'sqLibrary.db'
#########################################
# Category related functions
########################################
+def categorizeBook(bookid, category):
+ conn = sqlite3.connect(dbFile)
+ c = conn.cursor()
+ if isinstance(category,str):
+ query = "INSERT OR IGNORE INTO "+categoryTable+" (category) VALUES ("+stringify(cat)+");"
+ conn.commit()
+ c.execute(query)
+ query = "SELECT cat_id FROM "+categoryTable+" WHERE category = "+stringify(category)+";"
+ c.execute(query)
+ category = c.fetchone()
+ query = "INSERT OR IGNORE INTO "+bookCategoryTable+" (id,cat_id) VALUES ("+str(bookid)+", "+str(category)+");"
+ conn.commit()
+ c.close()
+
+
def getCategories():
conn = sqlite3.connect(dbFile)
c = conn.cursor()
conn = sqlite3.connect(dbFile)
c = conn.cursor()
query = "INSERT OR IGNORE INTO "+categoryTable+" (category) VALUES ("+stringify(cat)+");"
- c.execte(query)
+ print >>sys.stderr, query
+ c.execute(query)
+ conn.commit()
c.close()
#########################################