Couple more checkout related functions
This commit is contained in:
parent
af94db4071
commit
84548f5332
20
db_layer.py
20
db_layer.py
|
@ -65,7 +65,7 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################3
|
#################################
|
||||||
# character escaping, etc for sql queries
|
# character escaping, etc for sql queries
|
||||||
#################################
|
#################################
|
||||||
def _colify(s):
|
def _colify(s):
|
||||||
|
@ -332,6 +332,24 @@ def get_checkedout_books():
|
||||||
c.close()
|
c.close()
|
||||||
return books
|
return books
|
||||||
|
|
||||||
|
def get_onshelf_books():
|
||||||
|
'''
|
||||||
|
retrieves checked out books. The returned books also have the fields
|
||||||
|
uwid: ID of person who signed out the book, and
|
||||||
|
date: date when the book was checked out
|
||||||
|
'''
|
||||||
|
conn = sqlite3.connect(_catalogue_db_file)
|
||||||
|
c = conn.cursor()
|
||||||
|
query = 'ATTACH "' + _checkout_db_file + '" AS co'
|
||||||
|
c.execute(query)
|
||||||
|
query = ("SELECT "+",".join(map(_colify,columns))+" FROM "+_book_table+
|
||||||
|
" LEFT JOIN co."+_checkout_table+
|
||||||
|
" USING (id) WHERE uwid ISNULL;")
|
||||||
|
c.execute(query)
|
||||||
|
books = [_query_to_book_checkout(b) for b in c]
|
||||||
|
c.close()
|
||||||
|
return books
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Database initialization
|
# Database initialization
|
||||||
#########################################
|
#########################################
|
||||||
|
|
Loading…
Reference in New Issue