def findTotal(patronID):
# function to get the total amount of fines owed for a patron, not just the weekly fines
# Does lookup based on patron id
sum = 0.0;
# make connection to the database
dsn = cx_Oracle.makedsn("localhost","1521","VGER")
con = cx_Oracle.connect(user="READ-ONLY-DBA-USER",password="READ-ONLY-DBA-PASS",dsn=dsn)
cur = con.cursor()
# run the query
query = """
SELECT sum(fine_fee_balance)
FROM fine_fee
WHERE patron_id='{pID}'
"""
cur.execute(query.format(pID=patronID));
try:
sum = cur.fetchone()[0]
except:
sum = 0.0
return sum
评论列表
文章目录