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,这是正确的。