Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pytest runtimeerror: no application found. either work inside a view function or push an application context

#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()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pytest #application #work #view #function #push #application #context
ADD COMMENT
Topic
Name
1+5 =