MCPcopy Create free account
hub / github.com/MetapriseAI/OrgKernel / get_session_factory

Function get_session_factory

src/orgkernel/database.py:62–73  ·  view source on GitHub ↗

Return a session factory bound to the given engine. Usage:: factory = get_session_factory(engine) async with factory() as session: await session.execute(...)

(engine: AsyncEngine)

Source from the content-addressed store, hash-verified

60
61
62def get_session_factory(engine: AsyncEngine) -> type[AsyncSession]:
63 """
64 Return a session factory bound to the given engine.
65
66 Usage::
67
68 factory = get_session_factory(engine)
69 async with factory() as session:
70 await session.execute(...)
71 """
72 from sqlalchemy.orm import sessionmaker
73 return sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
74
75
76async def init_db(engine: AsyncEngine | None = None) -> None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected