试图通过Python运行MySQL脚本,它不断给我错误。这是我的MySQL:获取MySQL错误
c.execute("""INSERT into DATA(checkup_date)
VALUES(%s) WHERE machine_name = %s
""", (date, machine))
我在做什么错?
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 'WHERE machine_name = 'TL-D04'\nVALUES('2011-11-11')' at line 2")
粘贴错误,请 – Alfabravo
@JimGarrison:'%s'语法是MySQLdb中参数化SQL的工作原理。尤其要注意'%s'周围缺少引号。请执行Google搜索MySQLdb文档,然后放弃您的评论。 –
检查_mysql的源代码使我相信C API不使用预准备语句,因此容易受到SQL注入的影响。它似乎没有可以使用Python MySQLDB API来避免它。唉...... –