2015-07-09 300 views
6

在烧瓶SQLAlchemy,它在:瓶SQLAlchemy的设置expire_on_commit =假

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

您通过db.session访问到您的会话。

让你通过db.session访问会话如何有

expire_on_commit=False

我试图db.session.expire_on_commit = False但这并不appera生效。

+0

您需要使用'SQLALCHEMY_EXPIRE_ON_COMMIT'将它添加到应用程序设置中,但我必须问,为什么要这样做?您期望它做什么? –

回答

3

制作数据库对象时,可以使用session_options字典。

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