RuntimeError
在flask的学习中吗,出现了报错如下:
RuntimeError: Working outside of application context.
this typically means that you attempted to use functionality that needed
to interface with the current application object in some way. To solve
this, set up an application context with app.app_context(). See the
documentation for more information
我直接一手如下操作:
with app.app_context():
#操作的内容
就可以了
当然如果你是在命令行运行的话 需要先导入
from app import db,app #这里的db可以不用,我的出错场景是运行数据库操作的时候