test/backend/app/core/database.py
Z User 061e230b18 feat: Initial Moxiegen webapp implementation
- AI chat interface with file uploads
- Admin panel for managing OpenAI/Ollama endpoints
- User authentication with JWT
- SQLite database backend
- SvelteKit frontend with dark theme
2026-03-24 00:08:54 +00:00

22 lines
517 B
Python

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,
connect_args={"check_same_thread": False} if "sqlite" in settings.DATABASE_URL else {}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()