gpt4 book ai didi

python MySQL : error inserting data

转载 作者:太空宇宙 更新时间:2023-11-03 11:39:34 24 4
gpt4 key购买 nike

这是我的代码

qry = " INSERT INTO transactions(transaction_id,listing_id) VALUES ('%s','%s')"
cursor.execute(qry, ('123', '456',))
db_con.commit()

我遇到错误:

(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 '123'',''456'')' at line 1")

最佳答案

您正在使用 SQL 参数(耶!),那些已经处理了正确的引用。您基本上用双引号引用了您的值(value)观。从查询中删除引号:

qry = " INSERT INTO transactions(transaction_id,listing_id) VALUES (%s,%s)"

关于 python MySQL : error inserting data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43093998/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com