一、报错信息及代码
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)"
二、错误分析
这个错误原因是在pycharm里敲代码时,将python语法与mysql语法混淆了。
mysql语法中的特殊信息(例如表头)都没有加引号的操作。
这将会导致信息插入失败。即语法错误。文章来源:https://www.toymoban.com/news/detail-572114.html
三、正确代码
只需要将表头信息名的引号全部去掉即可。文章来源地址https://www.toymoban.com/news/detail-572114.html
sql = "insert into crawl_spider (director,time,score) values (%s,%s,%s)"
到了这里,关于pycharm中的python与mysql(1064):“You have an error in your SQL syntax; check the manual that corresponds的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!