added function to get books in category to dbLayer

This commit is contained in:
John Ladan 2012-03-30 20:09:22 -04:00
parent 540a2b2b62
commit 85f9246bd2
1 changed files with 17 additions and 0 deletions

View File

@ -123,6 +123,23 @@ def getBooks():
c.close()
return books
def getBooksByCategory(cat):
conn = sqlite3.connect(dbFile)
c = conn.cursor()
query = "SELECT "+",".join(columns)+" FROM "+bookTable+" JOIN "+bookCategoryTable+" USING (id) WHERE cat_id = :id;"
c.execute(query,cat)
books = []
for b in c:
book = {}
i = 0
for k in columns:
if b[i]!=None:
book[k]=b[i]
i+=1
books.append(book)
c.close()
return books
def getRemovedBooks():
conn = sqlite3.connect(dbFile)
c = conn.cursor()