Python pandas ERROR 2006 (HY000): MySQL server has gone away
程序员文章站
2022-06-23 19:20:21
ERROR 2006 (HY000): MySQL server has gone away ......
之前在做python pandas大数据分析的时候,在将分析后的数据存入mysql的时候报ERROR 2006 (HY000): MySQL server has gone away
原因分析:在对百万数据进行分析的时候,由于分析逻辑有点复杂,导致消耗的时候有点多,触发了mysql connect_timeout机制,当分析结束后想把结果存入mysql的时候,连接早已经断开了。
解决方案:针对一些复杂的数据分析,将数据分片处理,并在每次执行mysql插入的时候判断连接是否断开(connection.ping(True)),若断开则重新建立连接。关于分片可以采用python dask进行并发计算
推荐阅读
-
ThinkPHP出现General error: 2006 MySQL server has gone away的解决方法
-
Python pandas ERROR 2006 (HY000): MySQL server has gone away
-
[mysql] [python] "MySQL server has gone away (BrokenPipeError(32, ‘Broken pipe’))
-
2006 – MySQL Server has gone away error during database imp_MySQL
-
ERROR 2006 (HY000) at line xx: MySQL server has gone away 解
-
远程连接mysql 这几天一直出现 2006 'MySQL server has gone away'
-
ERROR 2006 (HY000) at line xx: MySQL server has gone away 解
-
Python pandas ERROR 2006 (HY000): MySQL server has gone away
-
ThinkPHP出现General error: 2006 MySQL server has gone away的解决方法