簡體   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