py-postgresql中的引号

时间:2018-11-20 16:29:48

标签: python postgresql

我尝试重建此功能

def getElementArea(screen_area, element):
    db = postgresql.open(db_conf.connectionString())
    sql = "select " + element + " from screen_coordinates where screen_area = $1 and active = 1"
    data = db.query.first(sql, int(screen_area))
    return data

收件人

def getElementArea(screen_area, element):
    db = postgresql.open(db_conf.connectionString())
    sql = "select $2 from screen_coordinates where screen_area = $1 and active = 1"
    data = db.query.first(sql, int(screen_area), element)
    return data

但是有错误-无法确定参数$ 2的数据类型。如何解决?我使用py-postgresql

0 个答案:

没有答案