SQLAlchemy checkbox set expire_on_commit = False

In Flask-SQLAlchemy, at:

https://pythonhosted.org/Flask-SQLAlchemy/queries.html

you access the session through db.session .

How to make session access through db.session have

expire_on_commit=False

I tried db.session.expire_on_commit = False , but this does not affect the work.

+6
source share
1 answer

You can use the session_options dictionary when creating the database object.

 db = SQLAlchemy(app, session_options={"expire_on_commit": False}) 
+3
source

All Articles