【发布时间】:2014-01-16 01:22:06
【问题描述】:
我正在尝试从 MySQL 数据库中检索数据。
A = "James"
query = ("SELECT * FROM DB.tblusers WHERE UserName = %s ")
c = mysql.connector.connect(user='root', password='',
host='127.0.0.1',
database='DB')
cur1 = c.cursor()
cur1.execute(query, A)
给出以下错误信息:
mysql.connector.errors.ProgrammingError: 1064 (42000): 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 '%' at line 1
但是 SQL 在 mySQL Workbench 中工作。 有什么想法吗?
【问题讨论】: