原因:

使用了多线程,多线程共享了同一个数据库连接,但每个execute前没有加上互斥锁

方法:

方法一:每个execute前加上互斥锁

lock.acquire()
        cursor.execute(command,data)     
        lock.release()

方法二:

  每个线程拥有自己的数据库连接,即在线程调用函数中加上数据库连接代码

方法三:

所有线程共用一个连接池,需要考虑线程总数和连接池连接数上限的问题

pymysql.err.InternalError: Packet sequence number wrong - got 45 expected 0的更多相关文章

  1. pymysql.err.InternalError: (1054, "Unknown column 'None' in 'field list'")

    错误提示: Traceback (most recent call last): File "D:/projectwc/test/dd.py", line 43, in <m ...

  2. OpenStack安装keyston 错误BError: (pymysql.err.InternalError) (1071, u‘Specified key was too long; max key length is 767 bytes‘) [SQL: u‘\nCREATE TABLE migrate_ver

    折腾了两天的错误,BError: (pymysql.err.InternalError) (1071, u‘Specified key was too long; max key length is ...

  3. 报错:pymysql.err.InternalError: (1054, "Unknown column 'AType' in 'field list'")

    报错背景: 报错前sql代码展示: List = ['] # sql = "insert into test(id, name) value ("+"'"+ L ...

  4. pymysql.err.InternalError: (1205, 'Lock wait timeout exceeded; try restarting transaction')错误处理

    问题描述: 在使用pymysql库时,利用游标执行插入操作,产生错误,会出现pymysql.err.InternalError: (1205, 'Lock wait timeout exceeded; ...

  5. 解决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 ...

  6. sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1091, "Can't DROP 'users_ibfk_1'; check that column/key exists") [SQL: ALTER TABLE users DROP FOREIGN KEY users_ibfk_1]

    flask 迁移数据库报错 报错: sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1091, "Can't DROP ...

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

  8. Mysql失败,异常pymysql.err.InternalError: (1366, "Incorrect string value: '\\xF0\\x9D\\x90\\xBF;......

    问题描述: 插入Mysql时失败了,python代码报如下异常: pymysql.err.InternalError: (1366, "Incorrect string value: '\\ ...

  9. python pymysql.err.InternalError: (1366, "Incorrect string value: '\\xE9\\x9F\\xA9\\xE6\\xA2\\x85...

    python3使用pymysql报错:   image.png 代码: #插入数据 try: sql = 'INSERT INTO classb (a_id,name,age) VALUES (6,& ...

随机推荐

  1. url传参过程中文字需编码、解码使用

    1.链接进行编码跳转:window.location.href = encodeURI(url) 2.获取当前链接进行解码:decodeURI(window.location); 3.获取url中参数 ...

  2. Linux系统(和mac系统)chmod修改权限总结

    在 Mac 系统的终端上修改文件权限使用的是 Linux 中的 chmod 命令. chmod 用户+操作+权限+文件 用户部分:使用字母 u 表示文件拥有者(user),g 表示拥有者所在群组(gr ...

  3. yield学习笔记

    参考:http://www.dabeaz.com/finalgenerator/ from concurrent.futures import ThreadPoolExecutor import ti ...

  4. laravel之路由和控制器与视图

    路由和控制器: : 路由与视图: 访问:

  5. react-redux简单的记事本应用

    首先给大家普及一个方法: let data = [ {id:1,text:'手机',check:false}, {id:2,text:'电脑',check:false}, {id:3,text:'平板 ...

  6. ELK之使用packetbeat分析网络包流量

    介绍 packbeat是一个开源的实时网络抓包与分析框架,内置了很多常见的协议捕获及解析,如HTTP.MySQL.Redis等.在实际使用中,通常和Elasticsearch以及kibana联合使用, ...

  7. 腾讯云“智能+互联网TechDay”:揭秘智慧出行核心技术与创新实践

    现如今,地面交通出行与大家的生活息息相关.在当前城市道路日益复杂和拥挤的情况下,如何保证交通出行的安全和便捷相信是每个人以及众多专家.科研工作者重点关注的问题. “智慧交通”系统是解决交通发展瓶颈的有 ...

  8. mysql-cluster集群配置

    环境: centos7:192.168.1.16,192.168.1.170 mysql-cluster-community-7.6.8-1.el7.x86_64.rpm-bundle.tar 安装: ...

  9. C#中$的用法

    class Program { static void Main(string[] args) { string tbName = "User"; string colName = ...

  10. ip通信第七周

    局域网的优点:1.具有较高的数据传输率 2.具有较低的误码率 3.具有较低的时延 4.能进行广播 网桥的基本特征:1.网桥在数据链录层上实现局域网互连 2.网桥能够互连两个采用不同数据链路层协议,不同 ...