SQLAlchemy error MySQL server has gone away

前端 未结 6 2198
清酒与你
清酒与你 2021-02-05 07:58

Error OperationalError: (OperationalError) (2006, \'MySQL server has gone away\') i\'m already received this error when i coded project on Flask, but i cant underst

6条回答
  •  我寻月下人不归
    2021-02-05 08:28

    One more point to keep in mind is to manually push the flask application context with database initialization. This should resolve the issue.

    from flask import Flask
    from flask_sqlalchemy import SQLAlchemy
    db = SQLAlchemy()
    
    app = Flask(__name__)
    with app.app_context():
        db.init_app(app)
    

提交回复
热议问题