Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python MySQL:插入数据时出错_Python_Mysql_Python 2.7 - Fatal编程技术网

Python MySQL:插入数据时出错

Python MySQL:插入数据时出错,python,mysql,python-2.7,Python,Mysql,Python 2.7,这是我的密码 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

这是我的密码

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参数(耶!),并且这些参数已经负责正确的引用。你基本上是双重引用了你的价值观。从查询中删除引号:

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

您正在使用SQL参数(耶!),并且这些参数已经负责正确的引用。你基本上是双重引用了你的价值观。从查询中删除引号:

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

从查询中删除
双引号
引号:

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

从查询中删除
双引号
引号:

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

我认为应该是
值(%s,%s)
@khelwood,这是正确的。我认为应该是
值(%s,%s)
@khelwood,这是正确的。