Automated Action ca5dbb9088 Add complete simple messaging app with FastAPI
- Implement user authentication with JWT tokens
- Add messaging system for sending/receiving messages
- Create SQLite database with SQLAlchemy models
- Set up Alembic for database migrations
- Add health check endpoint
- Include comprehensive API documentation
- Support user registration, login, and message management
- Enable conversation history and user listing
2025-06-26 16:07:21 +00:00

26 lines
581 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from app.db.base import Base
DB_DIR = Path("/app/storage/db")
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
Base.metadata.create_all(bind=engine)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()