【发布时间】:2012-10-05 20:30:04
【问题描述】:
我在这个网站上看到过以各种方式提出的这个问题,但没有一个能完全解决我的问题。
我有一个带有单引号的 sql 语句,并且在使用它进行数据库查询之前尝试使用推荐的做法。所以声明就像
val2="abc 'dostuff'"
sql="INSERT INTO TABLE_A(COL_A,COL_B) VALUES(%s,'%s')" %(val1, val2)
a_cursor.execute(sql)
但是,当我运行它时,我得到..
ProgrammingError: (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 'dostuff'.
我做错了什么? 非常感谢 努普尔
【问题讨论】:
-
尝试使用多行引号。 """ 或 '''
标签: python mysql mysql-python