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:
30
portfolio_app/toronto/models/base.py
Normal file
30
portfolio_app/toronto/models/base.py
Normal 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)
|
||||
Reference in New Issue
Block a user