from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from app.core.config import settings # Use a default SQLite database if no URL is provided if settings.database_url: DATABASE_URL = settings.database_url else: # Fallback to a local SQLite file (writable in the container) DATABASE_URL = "sqlite:///./app.db" # For SQLite, we need to disable the threading check connect_args = {"check_same_thread": False} if DATABASE_URL.startswith("sqlite") else {} engine = create_engine(DATABASE_URL, connect_args=connect_args) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) Base = declarative_base()