RuntimeError: Working outside of application context. RuntimeError: No application found. Either wor
RuntimeError: Working outside of application context.RuntimeError: No application found. Either work inside a view function or push an application context. See http://flask-sqlalchemy.pocoo.org/contex
·
RuntimeError: Working outside of application context.RuntimeError: No application found. Either work inside a view function or push an application context. See http://flask-sqlalchemy.pocoo.org/contexts/.
最近在使用flask项目时,有一个需求,定时往数据库中写入数据,代码没问题,但就是运行报错,查了下大概原因就是没有激活上下文前,就使用一些上下文的操作。
解决方法就是
from manage import app
def demo():
with app.app_context():
你的代码
更多推荐
已为社区贡献4条内容
所有评论(0)