cognee/cognee/infrastructure/databases/relational/get_async_session.py
Boris aaa1776293
feat: implement new local UI (#1279)
<!-- .github/pull_request_template.md -->

## Description
<!-- Provide a clear description of the changes in this PR -->

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.

---------

Co-authored-by: Daulet Amirkhanov <damirkhanov01@gmail.com>
2025-09-05 15:39:04 +02:00

15 lines
471 B
Python

from typing import AsyncGenerator
from contextlib import asynccontextmanager
from sqlalchemy.ext.asyncio import AsyncSession
from .get_relational_engine import get_relational_engine
@asynccontextmanager
async def get_async_session(auto_commit=False) -> AsyncGenerator[AsyncSession, None]:
db_engine = get_relational_engine()
async with db_engine.get_async_session() as session:
yield session
if auto_commit:
await session.commit()