原因:

使用了多线程,多线程共享了同一个数据库连接,但每个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. flask + MySQL-python 创建 webapp 应用

    0 - python 用自带的 wgsi 也可以创建 web 服务1)建立 hello.py 内容如下 # hello.pydef application(environ, start_respons ...

  2. Django聚合分组查询、常用字段

    首先回顾sql中聚合和分组的概念: 如果没有分组,会把整张表作为一个大组,查询字段必须是聚合结果:如果有分组,分组之后,必须要使用聚合的结果作为having的条件. 聚合查询 聚合:aggregate ...

  3. 如何让多个li居中于ul中间

    设置ul的display:table,text-align:center. 注意:不可以设置ul的宽,不然无法实现.

  4. hadoop2-hive

    hadoop2-hive 1.What,Why,How? 1.Hive是数据仓库,在MySQL或其他关系型数据库中存放元数据信息,而把真正的Data存放在HDFS上面. 2.主要使用Hive来对历史数 ...

  5. Solve Error: "errcode": 40016, "errmsg": "invalid button size hint"

    在使用微信官方给的添加自定义菜单的示例代码: { "button": [ { "name": "扫码", "sub_button& ...

  6. cadence单一原理图库的设计

  7. PPT领取 | 70+数据科学、架构演进等最佳实践限时放送

    上世纪1950年人工智能被提出,直至2016年AlphaGo战胜世界围棋冠军李世石后,人工智能迅速引起了全球的瞩目,并推动起全球科技的浪潮.自动驾驶.人脸识别.语音交互技术等“一拥而上”,众多AI科技 ...

  8. 杂_小技巧_将网页上的内容通过亚马逊邮箱传到kindle中

    所需条件 1.kindle要联网 2.要有亚马逊邮箱 3.要有微信,电脑上或者手机上 操作步骤: 1.找到你想要传送到kindle上的文章网页 2.在微信中关注“亚马逊kindle服务号”并且按照里边 ...

  9. task CancellationTokenSource

    使用CancellationTokenSource对象需要与Task对象进行配合使用,Task会对当前运行的状态进行控制(这个不用我们关心是如何控制的).而CancellationTokenSourc ...

  10. 关于Mysql6.0+的时区错乱问题

    如果使用mysql6.0+的JDBC驱动版本的时候,有时候会出现程序时间与数据库时间相差很多个小时; 1.如果以北京时间为例,相差8个小时的情况一般是你在连接jdbc的url中没有标明system_t ...