mirror of
https://gitverse.ru/kpa39l/telepost.git
synced 2026-09-29 18:05:08 +00:00
19 lines
481 B
Python
19 lines
481 B
Python
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
from sqlalchemy import create_engine
|
|
from typing import Generator
|
|
|
|
Base = declarative_base()
|
|
|
|
def get_db() -> Generator:
|
|
"""
|
|
Dependency to get database session
|
|
"""
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|
|
|
|
# Engine and session will be configured in database/database.py
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False) |