events updated

This commit is contained in:
2024-11-13 20:53:06 +03:00
parent 4199cc16b4
commit 83b3a5989e
9 changed files with 48 additions and 45 deletions

View File

@@ -10,13 +10,12 @@ engine_config = {
"pool_size": 10,
"max_overflow": 0,
"echo": False,
"isolation_level": "READ COMMITTED"
}
engine = create_engine(**engine_config)
session_config = {"autoflush": True, "bind": engine, "echo": True}
SessionLocal = sessionmaker(**session_config)
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False, echo=True)
session = scoped_session(sessionmaker(bind=engine))
session.expunge_all()
Base = declarative_base()
Base.session = session

View File

@@ -19,8 +19,18 @@ class AlchemyResponse:
@property
def data(self):
if self.first:
return self.__query.first()
return self.__query.all()
try:
return self.__query.first()
except Exception as e:
err = e
self.__query.session.expunge_all()
return None
try:
return self.__query.all()
except Exception as e:
err = e
self.__query.session.expunge_all()
return []
@property
def count(self):