archive-backend/core/db.py
2026-11-07 11:40:36 +00:00

27 lines
504 B
Python

from sqlalchemy.ext.asyncio import (
AsyncSession,
async_sessionmaker,
create_async_engine,
)
from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
pass
DB_URL = "postgresql+psycopg://ndmg:marselina5$@127.0.0.1:5432/rssdb"
engine = create_async_engine(DB_URL, echo=True)
SessionLocal = async_sessionmaker(
bind=engine,
expire_on_commit=False,
class_=AsyncSession,
)
async def get_db():
async with SessionLocal() as session:
yield session