Python:MySQLdb:错误:1064“您的 SQL 语法有错误。”
我是 MySQLdb 和 Python 的新手。我正在尝试执行以下语句:
header_string = 'number_one, number_two, number_three'
values = '1, 2, 3'
cursor.execute("""INSERT INTO my_table (%s) VALUES (%s)""", (header_string, values))
它返回以下错误:
错误:1064“您的 SQL 语法中有错误。”
根据我对 MySQLdb 的有限理解,上面的执行语句应该执行以下 SQL 语句:
INSERT INTO my_table (number_one, number_two, number_three) VALUES (1, 2, 3)
知道我可能做错了什么吗?
I'm new to MySQLdb and Python. I'm trying to execute the following statement:
header_string = 'number_one, number_two, number_three'
values = '1, 2, 3'
cursor.execute("""INSERT INTO my_table (%s) VALUES (%s)""", (header_string, values))
and it returns with the following error:
Error: 1064 "You have an error in your SQL syntax."
From my limited understanding of MySQLdb the above execute statement should execute the following SQL statement:
INSERT INTO my_table (number_one, number_two, number_three) VALUES (1, 2, 3)
Any ideas what I might be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
Try: