Answer the question
In order to leave comments, you need to log in
How to fix MySQL server has gone away error with peewee?
Hello
, I am developing a telegram bot in python. To work with MySql I use ORM - peewee.
After starting, everything works like clockwork without errors, but after some time errors appear and work with the database falls off.
I understand that at first peewee connects to the database for some time and MySql cuts the connection due to the duration.
How can I solve this problem so that peewee can work quietly with the database and not lose connection?
Answer the question
In order to leave comments, you need to log in
If the connection drops due to the duration of the script, then you need to increase the wait_timeout in the mysql settings, or, more correctly, change the logic of its work so that the work with the database is not spread over the entire execution time (You need a database - open the connection, do the work, close connection.But we didn’t open it during initialization, then we don’t do anything, the connection falls off, and then suddenly we needed it, and the request falls with an error).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question