📌  相关文章
📜  pytest 运行时错误:未找到应用程序.在视图函数中工作或推送应用程序上下文 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:08.250000             🧑  作者: Mango

代码示例1
#Push an application context when running db.create_all()
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'My connection string'
db.init_app(app)

# Add the with statement below to encapsulate db.create_all()
with app.app_context():
    db.create_all()