【发布时间】:2010-10-13 05:43:43
【问题描述】:
我收到类似这样的错误:
_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 't Stop.mp3' LIMIT 1' at line 1")
因为在我选择是否使用以下代码插入之前,我试图将数据库中存在的 URL 与变量中的 URL 进行比较:
`#see if any links in the DB match the crawled link
check_exists_sql = "SELECT * FROM LINKS WHERE link = '%s' LIMIT 1" % item['link'].encode("utf-8")
cursor.execute(check_exists_sql)`
显然' 字符和其他字符可能会导致问题。
如何格式化这些 URL 以避免这种情况?
【问题讨论】:
-
你认识一个叫Bobby Tables的人吗?