在更新内容SQL查询时处理'

时间:2021-05-27 15:40:05

I Have a sql query :-

我有一个SQL查询: -

"""UPDATE table SET column1 = '%s' WHERE columnId = '%s' """ %(columnContent,columnId)

When i'm updating some content like:

当我更新一些内容,如:

It caters to customers in more than 100 international destinations through its online portals at Macys.com. A major attraction is its events such as Macy's 4th of July Fireworks, Macy's Thanksgiving Day Parade, fashion shows, culinary events, flower shows, celebrity appearances and more.

它通过Macys.com上的在线门户网站迎合100多个国际目的地的客户。一个主要的吸引力是它的活动,如梅西的7月4日烟花,梅西的感恩节游行,时装秀,烹饪活动,花卉展览,名人出场等。

Then it gives an error:

然后它给出一个错误:

_mysql_exceptions.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 's 4th of July Fireworks' at line 1")

_mysql_exceptions.ProgrammingError:(1064,“你的SQL语法有错误;请查看与你的MySQL服务器版本相对应的手册,以便在第1行的7月4日Fireworks附近使用正确的语法”)

Please help me.

请帮帮我。

1 个解决方案

#1


1  

It should be:

它应该是:

"""
   UPDATE table
   SET column1=%s
   WHERE columnId=%s
""", (columnContent, columnId)

#1


1  

It should be:

它应该是:

"""
   UPDATE table
   SET column1=%s
   WHERE columnId=%s
""", (columnContent, columnId)

相关文章