Why does Sqlalchemy fail to insert big amounts of data to MySQL

Solution 1:

The most common reason for this error is that the server timed out and closed the connection. This could happen for large datasets. Try using a chunksize:

table.to_sql('TEST', connection, chunksize=1000, if_exists='replace', index=False)