【发布时间】:2016-03-02 13:34:38
【问题描述】:
我想在 where 子句中使用带有变量的 select 语句。我已经对 How to use variables in SQL statement in Python? 和 Inserting Variables MySQL Using Python, Not Working 进行了研究。我试图实施提供的解决方案,但它不起作用。错误代码
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
代码如下:
name = input("Write your name")
mycursor.execute("SELECT name FROM workers WHERE symbol=?", name)
我做错了什么?
【问题讨论】:
标签: python mysql mysql-connector