mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
23 lines
660 B
Python
23 lines
660 B
Python
"""Database configuration."""
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
from app.core.config import settings
|
|
|
|
engine = create_engine(settings.DATABASE_URL)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
Base = declarative_base()
|
|
|
|
# Import all models here
|
|
from app.models.employee import Employee # noqa
|
|
from app.models.request import Request # noqa
|
|
from app.models.chat import Chat, Message, ChatFile # noqa
|
|
|
|
def get_db():
|
|
"""Get database session."""
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close() |