python pymysql.err.InternalError: (1366, "Incorrect string value: '\\xE9\\x9F\\xA9\\xE6\\xA2\\x85...
python3使用pymysql报错:

代码:
#插入数据
try:
sql = 'INSERT INTO classb (a_id,name,age) VALUES (6,"韩",12)'
cur.execute(sql)
except Exception as e:
print(e)
解决办法一:
修改创建连接位置,设置字符编码:
db = pymysql.connect(user='root',password='123456',database='1609k',charset='uft8')
#或者
db = pymysql.connect(user='root',password='123456',database='1609k',charset='UTF8')
如果还是报错,修改Mysql编码格式:
show variables like 'character%';

修改: set character_set_database=utf8;
再次查看:

此时再次创建数据库,创建新表,问题解决。
对于已经存在的数据库和表格,修改:
修改数据库编码格式: Alter database 数据库名称 character set utf8 collate utf8_general_ci;
修改表编码格式: Alter table 表名称 convert to character set utf8;
查看数据库的编码格式: show create database 数据库名称;
python pymysql.err.InternalError: (1366, "Incorrect string value: '\\xE9\\x9F\\xA9\\xE6\\xA2\\x85...的更多相关文章
- 解决pymysql.err.InternalError: (1366, "Incorrect string value: '\\xF0\\x9F\\x8C\\xB8' for column 'headline' at row 1")
解决pymysql.err.InternalError: (1366, "Incorrect string value: '\\xF0\\x9F\\x8C\\xB8' for column ...
- Mysql失败,异常pymysql.err.InternalError: (1366, "Incorrect string value: '\\xF0\\x9D\\x90\\xBF;......
问题描述: 插入Mysql时失败了,python代码报如下异常: pymysql.err.InternalError: (1366, "Incorrect string value: '\\ ...
- sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1366, "Incorrect string value: '\\xE6\\xB1\\x89\\xE8\\xAF\\xAD...' for column 'className' at row 1") [SQL: INSERT INTO classmessage (`classId
sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1366, "Incorrect string value: '\\xE ...
- django 连接MYSQL时,数据迁移时报:django.db.utils.InternalError: (1366, "Incorrect string value: '\\xE9\\x97\\xAE\\xE9\\xA2\\x98' for column 'name' at row 5")
django 连接MYSQL时,数据迁移时报:django.db.utils.InternalError: (1366, "Incorrect string value: '\\xE9\\x ...
- django更换数据库时提示"django.db.utils.InternalError: (1366, "Incorrect string value: '\\xE7\\x94\\xA8\\xE6\\x88\\xB7' for column 'name' at row 1")"
问题提出 昨天在运行django时,初始化使用的是自带的数据库,后来更换mysql数据库,数据库同步之后,打开mysql无法添加数据,插入数据时,提示django.db.utils.InternalE ...
- MySQL (1366, "Incorrect string value: '\\xF0\\x9F\\x8E\\xAC\\xE5\\x89...' for column 'description' at row 1")
(1366, "Incorrect string value: '\\xF0\\x9F\\x8E\\xAC\\xE5\\x89...' for column 'description' at ...
- mysql General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'dianpumiaoshu' at row 1 解决方法
mysql General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'dianpumi ...
- MySQL Error:Warning: (1366, "Incorrect string value: '\\xF0\\x9F\\x98\\x82\\xF0\\x9F...' for column 'xxx' at row 2")
bug现象 使用连接数据库的可视化软件插入 emoj 表情数据.生僻字,可以正常插入.(导致我一直以为跟表情没有任何关系,谷歌出来一堆跟修改数据库.表.字段 的编码的结果....)但是一启动程序插入新 ...
- mysql保存数据提示1366 Incorrect string value: ‘\xF0\x9F\x98\x8A\xF0\x9F…’ 解决
在保存数据时我们如果页面编辑与数据库字段编码不一样或字符集超出你了mysql数据库中的字符类型就有可能出一\\xF0\\x9F\\x98\\x8A\\xF0\\x9F提示了,下面我来简单的解决方法. ...
随机推荐
- 初识Haskell 五:自定义数据类型和类型类
对Discrete Mathematics Using a Computer的第一章Introduction to Haskell进行总结.环境Windows 自定义数据类型 data type de ...
- Python----多项式回归
多项式线性回归 1.多项式线性方程: 与多元线性回归相比,它只有一个自变量,但有不同次方数. 2.举例: import numpy as np import matplotlib.pyplot as ...
- JAVA的三个版本,JSE,JEE,JME三者之间的区别
JAVA是一种面向对象语言由SUN公司出品 J针对不同的使用方向规划出JSE,JEE,JME三个版本 1.JSE 指标准版一般用于用户学习JAVA语言的基础也是使用其他两个版本的基础主要用于编写C/S ...
- LR socket协议脚本
socket协议分为TCP.UDP两种(区别与联系在此不做赘述),一种为长连接.一种为短连接.如果创建连接时在init中对应关闭连接在end中,则为长连接:如果创建关闭连接都是在action则为短连接 ...
- C#中 SQL语句
SQL语句 SELECT STUFF(( (SELECT ',{' ),)) ),)) ),)) +'}' FROM ZSJTTD_HouseBuilding hb ,,'' ) HouseBuild ...
- Binding介绍
一.Binding的源与路径 在大多数情况下Binding的源是逻辑层的对象,但有时候为了让UI元素产生一些联动效果也会使用Binding在控件间建立关联, 下面的代码是把一个TextBox的Text ...
- XML fragments parsed from previous mappers already contains value for xxxxx
错误信息: Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file ...
- 一、查看MVC4还是MVC5
一.查看MVC版本找到那个dll.属性.就可以看到版本 二.MVC添加WebAPI Visual Studio 已向项目“Web”添加 ASP.NET Web API 2 的 全部集合 个依赖项. 项 ...
- Jetson TX1使用usb camera采集图像 (1)
使用python实现 https://jkjung-avt.github.io/tx2-camera-with-python/ How to Capture and Display Camera Vi ...
- 树莓派3B+(一)
第一步:安装raspbian系统 介绍:Raspbian是为树莓派设计,基于Debian的操作系统,由一个小团队开发.其不隶属于树莓派基金会,但被列为官方支持的操作系统. 下载地址:https://w ...