finefeequery.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:autocirc 作者: cherveny 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号