FastAPI + Celery + Redis + MariaDB stack with 6-service docker-compose. Includes project skeleton (config, database, models, tasks, migrations) and health endpoint with passing test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
443 B
Python
25 lines
443 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import DeclarativeBase, sessionmaker
|
|
|
|
from web.config import settings
|
|
|
|
engine = create_engine(
|
|
settings.DATABASE_URL,
|
|
pool_pre_ping=True,
|
|
pool_recycle=3600,
|
|
)
|
|
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|