将MySql命令与变量一起保存为变量

时间:2018-12-04 12:54:06

标签: python mysql

因此,我需要将sql命令另存为变量,但是sql命令中包含变量。下面是我的代码的基本版本。

name = "a name in my table"
command = ("SELECT * FROM master WHERE name = %s ORDER BY descending DESC",(name))
c.execute(*command)

现在它给了我这个错误:

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 '%s ORDER BY descending DESC' at line 1

0 个答案:

没有答案