I'm encountering problem with MySQL. I'm getting error Lost connection to MySQL server during query
. On StackOverflow they say that very likely max_allowed_packet
in MySQL config is too low.
I've tried to change it in /etc/mysql/my.cnf
but the file isn't editable. sudo
can't be used on PA.
I'm using Sqlalchemy to handle interaction with MySQL server.
What can I do ?
Edit:
I've passed it into config variable:
class ProductionConfig:
SQLALCHEMY_DATABASE_URI = 'mysql://myconnection@server$db?max_allowed_packet=32M'
and then passed it into app and db initialization:
app.config.from_object(ProductionConfig)
db.init_app(app) # db = Sqlalchemy()
output:
TypeError: 'max_allowed_packet' is an invalid keyword argument for connect()
Problem went away after I increased pool recycling:
with Sqlalchemy:
class Config:
SQLALCHEMY_DATABASE_URI = 'mysql://<your-connection-string>'
SQLALCHEMY_POOL_RECYCLE = 280
this wasn't my idea. A member of staff at PythonAnywhere suggested it.