I encountered a problem with MySQL and SQL alchemy when trying to run a large insert. Considering other inserts were working perfect it made me suspect that there was a tress hold in place which would not pass the large commit. I looked at the different settings and finally found out it was due to a too small maxallowedpacket value. I increased the value to 64M which solved my problem.
Depending if you are running Linux or Windows you should look for my.conf (Linux) or my.ini and edit the value maxallowedpacket. Look for the following section:
[mysqld] port = 3306 socket = /tmp/mysql.sock skip-external-locking keybuffersize = 256M maxallowedpacket = 64M <====== tableopencache = 256 sortbuffersize = 1M readbuffersize = 1M readrndbuffersize = 4M myisamsortbuffersize = 64M threadcachesize = 8 querycachesize= 16M thread_concurrency = 8You can also use the MySQL Workbench tool by clicking on the Home button on the top left, then opening the server administration window, click on the "Options File" file in the left menu-bar under configuration. Proceed by opening Networking tab and changing the value for maxallowedpacket and click the apply button. Restart your MySQL server and profit.