繁体   English   中英

Mysql Connector错误1064-使用URL更新

[英]Mysql Connector error 1064 - Update with URL

我正在使用python开发Twitter应用程序,并且正在尝试更新数据库中的用户记录。 我可以很好地插入,但是更新时出现以下错误:

mysql.connector.errors.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 '://pbs.twimg.com/profile_images/
735726715267679398/m%HAWxt7_normal.jpg WHERE use' at line 1

以下是我用于UPDATE的代码:

cursor.execute("UPDATE user_table SET following='" + 
str(all_data['user']['following']) + "', followers_count=" + 
str(all_data['user']['followers_count']) + ", favourites_count=" + 
str(all_data['user']['favourites_count']) + ", friends_count=" + 
str(all_data['user']['friends_count']) + ", statuses_count=" + 
str(all_data['user']['statuses_count']) + ", verified=" + 
str(all_data['user']['verified']) + ", profile_image_url=" + 
all_data['user']['profile_image_url'] + " WHERE user_id=" + 
str(all_data['user']['id']))

然后,我将SQL打印到以下屏幕:

UPDATE user_table SET following='None', followers_count=252, 
favourites_count=3899, friends_count=12, statuses_count=506, 
verified=False, profile_image_url='http://pbs.twimg.com/profile_images
/735726715267679398/m%HAWxt7_normal.jpg' WHERE user_id=2933205672

我已将此SQL粘贴到phpmyadmin中并运行了SQL,它执行了更新,没有任何错误。 谁能看到解决方案?

Jens对准备好的陈述是正确的。 这不仅难以调试,而且还存在安全风险。 您很容易受到SQL注入的攻击。

无论如何,我认为您的问题是缺少引号。

...", profile_image_url='" + all_data['user']['profile_image_url'] + "' WHERE user_id="...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM