如题:代码如下
def clear_tables_null(self, table_name, field='价格'):
#table是字符串'商品'
print(table_name,field)
#已知可能被注入
query = "delete from %s where %s is null" % (table_name,field)
#???
query = "delete from %s where %s is null"
self.cursors.execute(query, (table_name,field))
self.conn.commit()这段已经被认为是错误的sql格式,请问为什么呢
问题如下:当我使用第一个query时可以运行,但使用第二个query的时候却报错了,错误代码1024,显示语法错误,我没有找到问题到底在哪?我又该如何更改使得该代码在防止sql注入的前提下能正常运行
错误代码:
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''304内六角' where '价格' is null' at line 1")
这里的意思是语法错误,这个可能要结合数据库来看
提示你 这个附近错误 '304内六角' where '价格' is null 那你完整sq是什么样呢