my-favs/backend/app/database.py
RamonCalvo aea7bf5ada feat: add bookmarks CRUD API with FastAPI and Docker Compose
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>
2026-03-28 18:37:23 -06:00

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