Couple more checkout related functions

This commit is contained in:
John Ladan 2013-12-13 13:40:41 -05:00
parent af94db4071
commit 84548f5332
1 changed files with 19 additions and 1 deletions

View File

@ -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
######################################### #########################################