ucca_db.py 文件源码

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

项目:nn4nlp-code 作者: neubig 项目源码 文件源码
def get_by_xid(db, host, xid, graceful=False):
    """Returns the passages that correspond to the xid

        Optional:
        graceful: True if no excpetions are to be raised
        excpetion raised if xid does no exist
    """
    # precaution for bad input e.g. 101->'101'
    xid = str(xid)
    cur = get_cursor(db, host)
    cur.execute("SELECT xml FROM xmls WHERE id" + "=" +
                PLACE_HOLDER, (int(xid),))
    raw_xml = cur.fetchone()
    if not raw_xml and not graceful:
        raise Exception("The xid " + xid + " does not exist")
    elif raw_xml:
        return fromstring(raw_xml[0])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号