Python 熊猫:“;与MySQL服务器的连接中断”&引用;系统错误:32断管“;

Python 熊猫:“;与MySQL服务器的连接中断”&引用;系统错误:32断管“;,python,mysql,pandas,sqlalchemy,Python,Mysql,Pandas,Sqlalchemy,我在尝试导入数据帧时遇到上述错误: import pandas as pd from sqlalchemy import create_engine engine = create_engine('mysql://username:password@localhost/dbname') c = getsomedata() fields = ['user_id', 'timestamp', 'text'] c1 = c[fields].reset_index() c1.to_sql(name='c

我在尝试导入数据帧时遇到上述错误:

import pandas as pd
from sqlalchemy import create_engine
engine = create_engine('mysql://username:password@localhost/dbname')
c = getsomedata()
fields = ['user_id', 'timestamp', 'text']
c1 = c[fields].reset_index()
c1.to_sql(name='comments', con=engine, if_exists='replace', index=False)

这个MySql问题有很多问题,但是如何通过熊猫导入解决呢?

我的解决方案非常简单:使用
chunksize
选项:

c1.to_sql(name='comments', con=engine, chunksize=1000, if_exists='replace', index=False)
                                       ^^^^^^^^^^^^^^^

可能与数据包过大有关。

我的解决方案非常简单:使用
chunksize
选项:

c1.to_sql(name='comments', con=engine, chunksize=1000, if_exists='replace', index=False)
                                       ^^^^^^^^^^^^^^^

可能与超大数据包有关。

这节省了我的时间。谢谢你@Erichbschulz这救了我一天。谢谢你@ErichBSchulz