MCPcopy Create free account
hub / github.com/DJWOMS/fastapi_base / get_db_session

Method get_db_session

config/database/db_helper.py:32–42  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

30
31 @asynccontextmanager
32 async def get_db_session(self):
33 from sqlalchemy import exc
34
35 session: AsyncSession = self.session_factory()
36 try:
37 yield session
38 except exc.SQLAlchemyError as error:
39 await session.rollback()
40 raise
41 finally:
42 await session.close()
43
44
45db_helper = DatabaseHelper(settings_db.database_url, settings_db.DB_ECHO_LOG)

Callers

nothing calls this directly

Calls 1

rollbackMethod · 0.45

Tested by

no test coverage detected