peewee.OperationalError: MySQL server has gone away

@beckerfuffle

Quick update: Just working on the fix for this problem! If you have a second, would you be able to test the following two little scripts with your Prodigy database?

I want to verify that explicitly closing and reconnecting does indeed solve the problem – but I’m not 100% sure if my test setup is fully representative. I’m using 30 seconds as the timeout, since 28800ms is apparently the default MySQL wait_timeout – but if you’re using a custom configuration, you might have to adjust this.

Example 1: should produce the error

import time
from peewee import MySQLDatabase

db = MySQLDatabase('your_prodigy_db', user='user', password='password')
db.connect()
db.execute_sql('SELECT * FROM Dataset')  # execute arbitrary query
time.sleep(30)                           # sleep for the wait_timeout
db.execute_sql('SELECT * FROM Dataset')  # try query again
# this should produce the "MySQL server has gone away" error

Example 2: should work

import time
from peewee import MySQLDatabase

db = MySQLDatabase('your_prodigy_db', user='user', password='password')
db.connect()
db.execute_sql('SELECT * FROM Dataset') 
time.sleep(30)          
db.close()    # explicitly close the connection
db.connect()  # explicitly reconnect
db.execute_sql('SELECT * FROM Dataset') 
# this should work now!

(Btw, as an alternative quick fix to keep working with your MySQL database until we release the next Prodigy update, you could also try increasing the wait_timeout temporarily.)