feat: add Pydantic schemas, SQLAlchemy models, and parser structure

Sprint 3 implementation:
- Pydantic schemas for TRREB, CMHC, and dimension data validation
- SQLAlchemy models with PostGIS geometry for fact and dimension tables
- Parser structure (stubs) for TRREB PDF and CMHC CSV processing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-11 14:58:31 -05:00
parent 549e1fcbaf
commit ead6d91a28
11 changed files with 760 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
"""SQLAlchemy base configuration and engine setup."""
from sqlalchemy import Engine, create_engine
from sqlalchemy.orm import DeclarativeBase, Session, sessionmaker
from portfolio_app.config import get_settings
class Base(DeclarativeBase): # type: ignore[misc]
"""Base class for all SQLAlchemy models."""
pass
def get_engine() -> Engine:
"""Create database engine from settings."""
settings = get_settings()
return create_engine(settings.database_url, echo=False)
def get_session_factory() -> sessionmaker[Session]:
"""Create session factory."""
engine = get_engine()
return sessionmaker(bind=engine)
def create_tables() -> None:
"""Create all tables in database."""
engine = get_engine()
Base.metadata.create_all(engine)