pymysql 1064, 'You have an error in your SQL syntax; check the manual that corresponds to
在python 连接mysql时,最近一直出现了
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 \'"58 convenience stores in Beijing Pilot selling class B over-the-counter drugs""\' at line 4'
这个异常信息,今早发现后就进行解决,尝试了多种方式,google提示用pymysql.escape_string函数对参数防止转义,最开始用的是{0} 这种占位符的方式,发现还是无法解决,后面还试了一种方式,在execute里面处理
sql_01 = '''
insert into cmstop_content(contentid,catid,modelid,title, tags,status,published,publishedby
,createdby,created,modifiedby,modified,sourceid,score)
values (null,%s,"1",%s,%s,'3',UNIX_TIMESTAMP(SYSDATE()),'28','28',UNIX_TIMESTAMP(SYSDATE()),'28',UNIX_TIMESTAMP(SYSDATE()),'21','0');
在execute的时候进行参数传递,可以正常入库了
cur.execute(sql_01, (pymysql.escape_string(info["flag"]), pymysql.escape_string(info["标题"]), pymysql.escape_string(info["标签"])))
以前都是将参数与sql处理好一起传入excute,没怎么用过在execute中传递参数,特意看了下execute的定义,args的类型可以是tuple,list,dict中的任何一种,如果参数类型不对,会出现如下提示:
execute() takes from 2 to 3 positional arguments but 5 were given
pymysql 1064, 'You have an error in your SQL syntax; check the manual that corresponds to的更多相关文章
- MySql 执行语句错误 Err] 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
关于用Power Designer 生成sql文件出现 错误 [Err] 1064 - You have an error in your SQL syntax; check the manual ...
- [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds...
INSERT INTO `ftms_active_dealer`(dealer_code,dealer_name,active_id,dealer_state)VALUES('415A1','贺磊'1 ...
- 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 'groups)VALUES('1','hh','hh@163.com','Boss')' at line 1
mysql8.0版本 在已存在的表里插入一条数据 insert INTO api_user(id,username,email,groups)VALUES('1','hh','hh@163.com', ...
- 插入mysql语句报错: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
插入一个很简单的sql语句时候,mysql一直报错: [SQL] INSERT INTO ORDER ( id, activity_id, order_type, phone, order_amoun ...
- [Err] 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 ''<h1 style="text-align: center;">php
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s ...
- 插入数据库失败([Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version)
报错信息如下: , ) 原因,read是数据库的关键字, 牢记,如果一个词是数据库的关键字,那么在写数据库语句的时候,这个词一定是蓝色的(关键字颜色)!!
- Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your My
转自:https://blog.csdn.net/haha_66666/article/details/78444457 Query : select * from order LIMIT 0, 10 ...
- [Err] 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 'number primary key,
如题,mysql建表语句报错 分析:就是一个语法错误,具体问题具体分析 本例中,直接赋值过来的 sql建表语句,直接粘贴到mysql数据库运行,报错! 经查询,mysql中 number类型的定义有如 ...
- Django进行数据迁移时,报错:(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 '(6) NOT NULL)' at line 1")
进行数据迁移时: 第一步: 命令:python manage.py makemigrations 在对应的应用里面的migrations文件夹中产生了一个0001_initial.py文件 第二步:执 ...
随机推荐
- Apache配置优化一(查看当前apache数据)
1.查看当前的运行模块 httpd -l 2.查看httpd进程数 ps -ef | grep httpd | wc -l 3.查看请求80服务的client ip按照连接数排序 netstat -n ...
- spark在windows的配置
在spark-env.cmd添加一行 FOR /F %%i IN ('hadoop classpath') DO @set SPARK_DIST_CLASSPATH=%%i 修改:log4j.prop ...
- 记EXSI虚拟机CentOS7断电无法启动修复过程
参考:https://msd.misuland.com/pd/3148108429789233656 EXSI6.7安装虚拟机CentOS7.5 1804 断电后启动页面进度条很慢 最后出现如下提示 ...
- 斑马打印机ZT610有线IP地址设置
设定完毕IP地址后,将协议改为永久,并复位网络!设置完毕,复位网络!设置完毕,复位网络!设置完毕,复位网络! 不复位网络,设置无效!
- 【MM系列】SAP S/4 HANA的物料编码40位设置
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP S/4 HANA的物料编码4 ...
- CentOS系统安装配置mysql
一.mysql安装 安装mysql数据库: yum install -y mysql mysql-server 判断mysql是否启动成功: service mysqld start 二.mysql配 ...
- JDK+Jmeter 环境搭建
1.下载JDK安装包,默认安装next即可 2. 3. 4. 5. 6.变量名:JAVA_HOME 变量的值为你安装JDK的目录 我这里是放在C盘 7. 8.添加新的变量值: %JAVA_HOME%\ ...
- [转载]ftp和http区别
本文围绕以下三个部分展开: 一.HTTP协议 二.FTP协议 三.HTTP与FTP的异同点 一.HTTP协议简介 1. 概念 HTTP: HyperText Transfer Protocal,超文本 ...
- docker安装详细步骤-centos7
https://www.runoob.com/docker/centos-docker-install.html 一.安装docker 1.Docker 要求 CentOS 系统的内核版本高于 3.1 ...
- ROS下gazebo打开出现问题
通常情况下,在装完ros后,打开gazebo, 会出现无法连接服务器获取模型的情况.这样,我们打开gazebo, 终端会提示timeout,gazebo界面没有网格. 这是因为服务器网站地址好像已经换 ...