防止sql注入

# 存在sql注入
sql = """select * from info where code = '%s';""" % stock_code

# 避免通过stock_code进行sql注入
sql = """select * from info where code=%s;"""
cs.execute(sql, (stock_code,))  # 将stock_code以元组的方式传入
posted @ 2019-08-21 14:12  bitbitbyte  阅读(115)  评论(0)    收藏  举报