init commit

This commit is contained in:
2025-12-10 22:09:31 +09:00
commit b79adf1c69
361 changed files with 47414 additions and 0 deletions

36
app/db/database.py Normal file
View File

@@ -0,0 +1,36 @@
"""Database connection and session management"""
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from app.core.config import get_settings
settings = get_settings()
# Create database engine
engine = create_engine(
settings.database_url,
echo=settings.database_echo,
pool_pre_ping=True, # Verify connections before using them
pool_recycle=3600, # Recycle connections every hour
)
# Create session factory
SessionLocal = sessionmaker(
bind=engine,
autocommit=False,
autoflush=False,
expire_on_commit=False,
)
# Create declarative base for models
Base = declarative_base()
def get_db():
"""Dependency for FastAPI to get database session"""
db = SessionLocal()
try:
yield db
finally:
db.close()