Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask SQLAlchemy Set expire_on_commit=False

In Flask-SQLAlchemy, at:

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

you access to your session via db.session.

How do you make the session accessed via db.session have

expire_on_commit=False

I tried db.session.expire_on_commit = False but this does not appera to take affect.

like image 824
James Lam Avatar asked Jul 09 '15 23:07

James Lam


1 Answers

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

db = SQLAlchemy(app, session_options={"expire_on_commit": False})
like image 178
biw Avatar answered Sep 17 '22 13:09

biw