一、報(bào)錯(cuò)信息及代碼
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 '‘director’,‘star’,‘score’) values (‘奧利
維?!ぜ{卡什’,‘弗朗索瓦·克é’ at line 1”
sql = "insert into crawl_spider ('director','time','score') values (%s,%s,%s)"
二、錯(cuò)誤分析
這個(gè)錯(cuò)誤原因是在pycharm里敲代碼時(shí),將python語(yǔ)法與mysql語(yǔ)法混淆了。
mysql語(yǔ)法中的特殊信息(例如表頭)都沒(méi)有加引號(hào)的操作。
這將會(huì)導(dǎo)致信息插入失敗。即語(yǔ)法錯(cuò)誤。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-572114.html
三、正確代碼
只需要將表頭信息名的引號(hào)全部去掉即可。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-572114.html
sql = "insert into crawl_spider (director,time,score) values (%s,%s,%s)"
到了這里,關(guān)于pycharm中的python與mysql(1064):“You have an error in your SQL syntax; check the manual that corresponds的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!