Issue
I am getting the above errors.
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError)
(2013, 'Lost connection to MySQL server during query')
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError)
(2006, 'MySQL server has gone away')
we are using a lot of ORM queries, but we use the same connection/session and if one orm throws error the other fails due to invalid trx rollback error. Is it recommended to use each connection/session for each orm query??????
I am getting this error in sqlalchemy NOT flask-sqlalchemy and also our application runs as a gunicorn server, it is a flask application. The application runs under app factory.
Solution
Modify the max_allowed_packet
or net_read_timeout
in your MySQL configuration file. Or run the following queries:
SET GLOBAL max_allowed_packet=268435456;
SET GLOBAL net_read_timeout = 1000;
To Modify the MySQL Configuration check Setting max_allowed_packet.
Answered By - The Cool Cat
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.