added function to get books in category to dbLayer
This commit is contained in:
parent
540a2b2b62
commit
85f9246bd2
17
dbLayer.py
17
dbLayer.py
|
@ -123,6 +123,23 @@ def getBooks():
|
||||||
c.close()
|
c.close()
|
||||||
return books
|
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():
|
def getRemovedBooks():
|
||||||
conn = sqlite3.connect(dbFile)
|
conn = sqlite3.connect(dbFile)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
Loading…
Reference in New Issue