peewee.OperationalError: (2013, 'Lost connection to MySQL server during query')
You probably want to more closely monitor your connection setup/teardown. These docs may be relevant: http://docs.peewee-orm.com/en/latest/peewee/database.html#error-2006-mysql-server-has-gone-away

I've not seen that particular error. Probably best off trying to ask on StackOverflow and posting some more information about what exactly your application is doing when things break. Hi.
I have same problem after a while that my script is running. does it solve the issue that use `db.connect()` before **every** query and `db.close()` after it? or not? and is this efficient? > and is this efficient?

No.
I find that if mysql wait_timeout  value is set too low peewee will lost connection .

so peewee can't automatically release the connection ?

how do I deal with this problem?

thanks