feat: add database module

- Add SQLAlchemy database module with DeclarativeBase
- Implement engine and session factory management
- Add context manager for database sessions
- Add database initialization script
- Update models/__init__.py to import Base from database
- Fix Python 3.8 compatibility issues (use Optional instead of |)
- Ensure SQLite database file is created on init_db

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
panw
2026-03-30 15:26:31 +08:00
parent 8852fdf708
commit a1efa8a906
4 changed files with 141 additions and 10 deletions

View File

@@ -1,11 +1,3 @@
"""ORM Models.
from app.database import Base
NOTE: This module is a placeholder until Task 2.1.
The Base class is needed by conftest.py for database fixtures.
"""
from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
"""Base class for all ORM models."""
pass
__all__ = ['Base']