autocirc.py 文件源码

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

项目:autocirc 作者: cherveny 项目源码 文件源码
def findItemType(barCode):
    # function to get the type of an item, based on itemId.
    # checks for temporary item ID being set, if so, returns that type instead
    # Note: dicts field itemId isn't really itemId, it's item barcode
    # dict's barcode field is PATRON barcode
    itemType = "NONE";

    # make connection to the database
    dsn = cx_Oracle.makedsn(db_host,db_port,db_SID)
    con = cx_Oracle.connect(user=db_user,password=db_password,dsn=dsn)
    cur = con.cursor()

    # run the query
    query = """
        SELECT
            itt.item_type_name
        FROM
            item it,
            item_type itt,
            item_barcode ib
        WHERE
            ib.item_barcode IN ('{itemNumber}') AND
            ib.item_id = it.item_id AND
            itt.item_type_id = CASE WHEN (it.temp_item_type_id = '0') THEN it.item_type_id ELSE it.temp_item_type_id END
    """

    cur.execute(query.format(itemNumber=barCode));

    try:
        itemType    = cur.fetchone()[0]
    except:
        itemType = "NONE"

    if itemType == None:
        itemType = "NONE"

    return itemType;

##########Utility Functions
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号