在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的更多相关文章

  1. 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 ...

  2. [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 ...

  3. 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', ...

  4. 插入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 ...

  5. [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 ...

  6. 插入数据库失败([Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version)

    报错信息如下: , ) 原因,read是数据库的关键字, 牢记,如果一个词是数据库的关键字,那么在写数据库语句的时候,这个词一定是蓝色的(关键字颜色)!!

  7. 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 ...

  8. [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类型的定义有如 ...

  9. 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文件 第二步:执 ...

随机推荐

  1. JS CSS写下拉菜单 竖行

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. Spring 使用jsp

    1.New----新建项目 2.选择图中所示按钮,下一步 3.标记处修改工程名,下一步 4选中图中所示选项 5.完成 6.在main目录下新建目录webapp 7.自动导入 8.调整项目结构 9.选择 ...

  3. 搭建一个超好用的 cmdb 系统

    10 分钟为你搭建一个超好用的 cmdb 系统 CMDB 是什么,作为 IT 工程师的你想必已经听说过了,或者已经烂熟了,容我再介绍一下,以防有读者还不知道.CMDB 的全称是 Configurati ...

  4. mysql 按照配置文件启动

      有时,我们的机器上面装了很多个mysql,但只有一个3306端口,其余的mysql服务器需要重新指定端口.我们需要多个配置文件来启动它们.那么我们怎么通过指定配置文件的方式来启动呢?   例如,按 ...

  5. Vue.js与React的全面对比

    Vue与React的对比 Vue.js与React.js从某些反面来说很相似,通过两个框架的学习,有时候对一些用法会有一点思考,为加深学习的思索,特翻阅了两个文档,从以下各方面进行了对比,加深了对这两 ...

  6. 开源定时任务框架Quartz(一)

    简介 Quartz是OpenSymphony开源组织的一个开源项目,定时任务框架,纯Java语言实现,最新版本为2.3.0. 设计模式 Quartz中使用的设计模式如下: 1.Builder模式 2. ...

  7. Linux下安装redis 3.0及C语言中客户端实现demo

    1.获取安装文件 wget http://download.redis.io/redis-stable.tar.gz 2.解压文件 tar xzvf redis-stable.tar.gz 3.进入目 ...

  8. PAT甲级 进制转换题_C++题解

    进制转换题 PAT (Advanced Level) Practice 进制转换题 目录 <算法笔记> 重点摘要 1015 Reversible Primes (20) 1019 Gene ...

  9. Docker从国内代理下载镜像

          docker从国内拉取镜像,或者通过加速器拉取         由于国内访问直接访问Docker hub网速比较慢,拉取镜像的时间就会比较长.一般我们会使用镜像加速或者直接从国内的一些平台 ...

  10. JS 03事件

    <script type="text/javascript"> function getUserInput() { //获取用户输入的内容 var val = docu ...