Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# code_snippets
# code_snippets
## Flask-SQLAlchemy Version 3.0.0 update
- An active Flask application context is always required to access `session` and `engine`, regardless of if an application was passed to the constructor.
- Without an application context, creating db from terminal will raise `RuntimeError: Working outside of application context.` when you try to invoke `db.create_all()` from python interpreter.
- To counteract this issue, two solutions are presented:
1. `flask shell` offers made-ready app context and instance to create db.
2. Import app from FlaskBlog and create db under app context:
```
from flaskblog import app
with app.app_context():
db.create_all()
```