0
我正在Python的嘰嘰喳喳應用程序,我想更新我的數據庫中的用戶記錄。我可以插入不錯,但更新提供了以下錯誤:Mysql連接器錯誤1064 - 更新與URL
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
下面是我使用的更新代碼:
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查詢的?我不認爲,他們是一樣的。 – qvpham