Remove use of autocommit

Change-Id: I6e973935edf5e754ba054e724b6963b6d5fd795a
This commit is contained in:
Michal Nasiadka
2024-02-28 14:21:01 +00:00
parent a41c884463
commit d544698fae
2 changed files with 3 additions and 4 deletions

View File

@@ -47,9 +47,7 @@ _FACADE = None
def _create_facade_lazily():
global _FACADE
if _FACADE is None:
# FIXME(karolinku): autocommit=True it's not compatible with
# SQLAlchemy 2.0, and will be removed in future
_FACADE = db_session.EngineFacade.from_config(CONF, autocommit=True)
_FACADE = db_session.EngineFacade.from_config(CONF)
if profiler_sqlalchemy:
if CONF.profiler.enabled and CONF.profiler.trace_sqlalchemy:
profiler_sqlalchemy.add_tracing(sa, _FACADE.get_engine(), "db")

View File

@@ -93,7 +93,8 @@ class MagnumBase(models.TimestampMixin,
if session is None:
session = db_api.get_session()
super(MagnumBase, self).save(session)
with session.begin():
super(MagnumBase, self).save(session)
Base = declarative_base(cls=MagnumBase)