Mรณdulo 12 ยท Databases & SQLAlchemy โ Lecciรณn 1 de 4 ยท ~6 min
Tables as classes, again
Two classes, same walker
Back in module 21 you wrote class Walker(models.Model) in Django โ a class that IS a database table. The real PawWalk backend does the same thing with a different library: SQLModel, a thin layer over SQLAlchemy (Python's most-used database toolkit). The idea hasn't changed: one class, one table, one row per instance.
But this backend ALSO has app/schemas.py, full of classes like Walker(BaseModel) โ the Pydantic models from module 23. That's not a duplicate by accident. It's the big architecture lesson of this module: the database shape and the API shape are deliberately two different classes.