REST API for managing personal bookmarks (title, link, category). PostgreSQL database with async SQLAlchemy, containerized with Docker Compose. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
13 lines
405 B
Python
13 lines
405 B
Python
from collections.abc import AsyncGenerator
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
|
|
|
from app.config import settings
|
|
|
|
engine = create_async_engine(settings.database_url)
|
|
async_session = async_sessionmaker(engine, expire_on_commit=False)
|
|
|
|
|
|
async def get_db() -> AsyncGenerator[AsyncSession]:
|
|
async with async_session() as session:
|
|
yield session
|