RuntimeError: Working outside of application context.
OmarMohammed88 opened this issue · comments
when i am running the code, i got this error.
RuntimeError: Working outside of application context.
This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.
Notice that i had to change the sqlalchemy loading to the following code
app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql:///quokka"
and i tried to add app.app_context()
after db = SQLAlchemy(app)
but still, the error is raised in all threading process
Any solutions for this ?
Thanks for your prompt response, i will try to use SQLite to get it run
Apparently as of Flask-SQLAlchemy 3.0, all access to db.engine (and db.session) requires an active Flask application context. db.create_all uses db.engine, so it requires an app context, i also tried to push application context, but it raised the same errors on the threads.
Instead i required pip to install packages that was released in the time of development.
pip install Flask==2.1.1 pip install Flask-SQLAlchemy==2.5.1
fixed the issue.