最近在学python爬虫,再写入数据的时候写不进数据库。报了这个很常见的异常

pymysql.err.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 'rank,

多次检查语句,修改数据库格式还是不行,总是报这个错误。最后通过换参数位置突然发现,每次都是rank这里的问题,然后把数据库里的rank变量改名, 代码中的参数也改了,然后就行了。用了这么久数据库突然发现还有这个东西,属实惊呆我了

写入数据库rank变量不能用,需要修改其他名字

原代码

def process_item(self,item,spider):title = item.get('title', '')subject = item.get('subject', '')rank = item.get('rank', 0)self.cursor.execute("insert into movie(rank,subject,title) values (%s,%s,%s)",(rank,subject,title))return item

报错

pymysql.err.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 'rank,subject,
title) values ('8.3','过去的如果就让它过去了,未来只' at line 1")
2022-08-06 16:08:29 [scrapy.core.scraper] ERROR: Error processing {'rank': '8.7', 'subject': '世界离独裁只有五天。', 'title': '浪潮'}

修改后

def process_item(self,item,spider):title = item.get('title', '')subject = item.get('subject', '')rank = item.get('rank', 0)self.cursor.execute("insert into movie(raning,subject,title) values (%s,%s,%s)",(rank,subject,title))return item

运行成功

完美!!!

目前还不明确知道为什么不能用rank参数

猜测可能是函数或者一些特定名字吧,上网也没有查出所以然来,毕竟是写在sql语句中的。

如有知道为什么不能用rank或者还有其他不能用的名字的朋友,希望不吝赐教!

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version相关推荐

  1. 错误:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server vers

    错误:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server vers ...

  2. 数据库报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server v

    数据库出现 [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your M ...

  3. 报错,> 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL

    错误: idea: 2020-12-23 15:26:13.885 ERROR 17972 --- [MessageBroker-2] o.h.engine.jdbc.spi.SqlException ...

  4. 【报错】ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds t

    设置mysql中的root账户密码出现1064错误代码 ERROR 1064 (42000): You have an error in your SQL syntax; check the manu ...

  5. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your

    mysq5.7中报错 执行下面语句报错 mysql> grant replication slave on . to 'myslave'@'192.168.136.%' identified b ...

  6. 创建存储过程报错:1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQ

    自己写了一个创建存储过程的语句: create procedure abcd() begin       select * from area; end ; 语法什么的都没有错误,但是提示报错:106 ...

  7. ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your

    在MySQL中导入.sql文件时 通过 use data source C:/info.sql use data(数据库名称为data) source C:/info.sql(提前把.sql文件放入一 ...

  8. 一篇文章让你解决sql报错check the manual that corresponds to your MySQL server version for the right syntax to

    一篇文章让你解决sql报错 反馈 因为这一个问题,找到了很多类似问题,你在看到这篇博客时,可能不是这个,但是一定是下面其中一个: Mysql错误:check the manual that corre ...

  9. java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to yo

    今天踩了一个坑,报这种错误首先你可能会想到先去检查自己的SQL有没有写错,如果发现自己的SQL语句没有写错,那么就要注意了!经过排查才发现如下: 自己在数据库中原来使用的是order作为表名,而ord ...

最新文章

  1. RHEL6.4更改为CentOS6.4的yum源
  2. 将hadoop源代码导入eclipse
  3. SetComputerName改网络中计算机名
  4. 在Java EE应用程序中实现自动重试
  5. EJB通过ANT提高EJB应用程序的开发效率、无状态发展本地接口bean、开发状态bean...
  6. jQuery .tmpl() 用法
  7. Junit4单元测试报错
  8. glEnable(GL_DEPTH_TEST)作用
  9. rbenv Your user account isn't allowed to install to the system Rubygems
  10. 斐讯音箱控制扫地机器人_轻松解决家务难题 斐讯大能扫地机器人X3
  11. SCI/SSCI选刊神器之——Elsevier Journal Finder
  12. 单片机原理及应用c51语言版林立,单片机原理及应用——基于Proteus和Keil C(第4版)...
  13. Ubuntu 16.04-codeblocks 汉化
  14. 基于n元语言模型整句拼音汉字转换
  15. 努力赚钱,是为了不让自己的爱情受到别人金钱的考验--这就是现实
  16. 易经——第一卦 乾 乾为天 乾上乾下
  17. 杨洋告诉你实时异地容灾的重要性
  18. 微信分享网页时自定义标题、描述和图片
  19. kvm直通sata_将双系统塞入A4主机:OSX-KVM 显卡直通教程
  20. 年轻人宣言:青春符号

热门文章

  1. 商业数据分析【一】概述及职业发展
  2. vue移动端实现图片预览
  3. 动态色调范围 (网络整理)
  4. Android P的音频架构(二)
  5. Python变量的基本使用
  6. 从零开始系统学习C/C++,深度理解一门编程语言的应用与未来发展
  7. svn 项目文件出现左边红色箭头,右边绿色箭头的双箭头的解决方法
  8. cad安装日志文件发生错误_CAD因为发生错误安装过早结束 致命错误解决方法
  9. 【论文解读 WWW 2019 | HAN】Heterogeneous Graph Attention Network
  10. php类的定义与实例化方法