[英]python & mysql, Failed executing the operation; Could not process parameters
I have this code:我有这个代码:
my_cursor = my_db.cursor()
def Insert_object(Title, Details, Amount):
sql_command = 'INSERT INTO income (title, details, amount) VALUES (%s, %s, %d)'
values = (Title, Details, Amount)
my_cursor.executemany(sql_command, values)
my_db.commit()
Insert_object('Chips', 'Chili', 12)
but it throws the following error:但它会引发以下错误:
mysql.connector.errors.InterfaceError: Failed executing the operation; Could not process parameters
In MySQL documentation it says that the second argument of executemany
function is a list of tuples.在MySQL 文档中,它说
executemany
函数的第二个参数是元组列表。 Try changing values
so that it is a list that contains a single tuple.尝试更改
values
,使其成为包含单个元组的列表。
values = [(Title, Details, Amount)]
my_cursor.executemany(sql_command, values)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.