如何对 SQL 查询进行转义以避免SQL 注入?
def getStackArea(screen_area):
db = postgresql.open(db_conf.connectionString())
data = db.query("select stack_area from screen_coordinates where screen_area = " + screen_area + " and active = 1")
return data[0]['stack_area']
例子:
或使用
py-postgresql:PS 看起来参数化
py-postgresql没有完全实现,如 PEP-249 中所述