Add the data layer for the spending analysis app including models for household members, accounts, categories, transactions, categorization rules, and CSV import mappings. All models use SQLAlchemy 2.0 mapped columns with proper foreign key relationships. Includes db.py with Base class, engine/session factories, and 6 passing tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
22 lines
583 B
Python
22 lines
583 B
Python
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import String
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship as sa_relationship
|
|
|
|
from src.db import Base
|
|
|
|
if TYPE_CHECKING:
|
|
from src.models.account import Account
|
|
|
|
|
|
class HouseholdMember(Base):
|
|
__tablename__ = "household_members"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(100))
|
|
relationship: Mapped[str] = mapped_column(String(50))
|
|
|
|
accounts: Mapped[list[Account]] = sa_relationship(back_populates="owner")
|