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文件 第二步:执 ...
随机推荐
- LeetCode_189. Rotate Array
189. Rotate Array Easy Given an array, rotate the array to the right by k steps, where k is non-nega ...
- python介绍,计算机组成。内存分布,进制,操作系统介绍
学习小方法 三个W一个Hwwwh:what(是什么) why(为什么) where(怎么用) how(如何用) 来思考知识点多练,多写,多敲代码增加熟练度与代码量 Python 是一门面向后台的编 ...
- 字符串匹配算法---BF
Brute-Force算法,简称BF算法,是一种简单朴素的模式匹配算法,常用语在一个主串string 内查找一个子串 pattern的出现位置. 核心思想: i 遍历主串string i 每自增一次, ...
- 【ARM-Linux开发】TI AM437x调试WEB CAM
Rico Board是基于TI AM437x的一款小型学习板,提供的丰富的接口以及资源,能够实现很多有趣的idea,从本周起,开始总共四期的实验教程,帮助玩家们快速上手Rico Board在嵌入式上面 ...
- Android SDK目录说明
在SDK目录下有很多文件夹,了解这个文件夹都包含哪些内容,更有利于Android的开发,也是作为Android开发者应该了解的.本文就SDK目录进行说明. SDK目录如下: add-ones:Goog ...
- 项目中微信公众号调取支付控件demo
微信支付官方文档:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6 前端代码demo (JSP页面): ...
- 上传文件报错500或者文件大于2M上传不上去解决方法
修改php.ini 配置文件: 先找到配置文件------find / -name php.ini 打开php.ini修改内容:post_max_size ------ post请求上传参数的大小限制 ...
- sql语句中,取得schema中的所有表信息及表的定义结构
postgressql下'検索スキーマの中で.全てテーブルselect tablename from pg_tables where schemaname='test' mysql下'検索スキーマの中 ...
- ElasticSearch总结
转载自:https://www.cnblogs.com/WessonStar/p/8296781.html 不过我的es版本是7.2.0,然后这里要注意ik分词器放入plugins里是需要有个ik插件 ...
- MakeFile文件是什么——内容、工作原理、作用、使用
MakeFile文件是什么?它里面包含什么内容.具有什么作用.怎么使用?下面就来具体说说. 什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你 ...