B
B
bubaley2019-03-07 05:08:11
MySQL
bubaley, 2019-03-07 05:08:11

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.
5c807c6140b83849853123.png
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

2 answer(s)
B
Boris Syomov, 2019-03-07
@kotomyava

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).

A
Andrey, 2019-03-07
@VELIK505

How can I solve this problem so that peewee can work quietly with the database and not lose connection?

Well, for example, https://docs.oracle.com/cd/E17952_01/connector-pyt...
https://dev.mysql.com/doc/connector-python/en/conn...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question