Skip to content

What's the alternative to create_scoped_session in versions 3+ to create a session for the read replica? #1375

Discussion options

You must be logged in to vote

You can use the private attribute, with the understanding you're using something private that might change. Write tests so you catch if something does change in that case.

Creating a bunch of scoped sessions is probably not doing what you intended it to. It requires you actually accessing the session again in a new scope in order to clean up the old scope. Flask-SQLAlchemy manages this by calling session.remove() at request teardown. So you probably just want to create instances of flask_sqlalchemy.session.Session(db) instead.

You might want to look at Flask-SQLAlchemy-Lite as an alternative if you want to manage the session yourself anyway: https://flask-sqlalchemy-lite.readthedocs.io/en…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by andrii-korotkov-verkada
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy