Peewee MySQL server is gone

I use a flask and a peewee. Sometimes peewee throws this error

MySQL server has gone away (error(32, 'Broken pipe'))

Connect to the Peewee Database

db = PooledMySQLDatabase(database,**{
            "passwd": password, "user": user,
            "max_connections":None,"stale_timeout":None,
            "threadlocals" : True
        })

@app.before_request
def before_request():
    db.connect()

@app.teardown_request
def teardown_request(exception):
    db.close()

After the mysql error that "the MySQL server is gone (error (32," Broken pipe ")), query selection works without problems, but inserting, updating, deleting queries does not work.

Insertions, updates, query deletions work behind (in mysql), but peewee throws these errors.

(2006, "MySQL server has gone away (error(32, 'Broken pipe'))")
+4
source share
2 answers

The peewee documentation talked about this problem, here is the link: Error 2006: MySQL server disappeared

, MySQL . -, . , , , , , , , .

, .


, , :

@app.teardown_appcontext
def close_database(error):
    db.close()

: 3:

+5

, , , , .

, Peewee (, MySQL, MySQL ). , max_allowed_packet my.conf.

, my.conf, [mysqld]:

max_allowed_packet=50M

... mysqld

+3

Source: https://habr.com/ru/post/1618248/


All Articles