Skip to content

Oct 15: Querying with SQLModel

Learning Objectives

After today's class, you should be able to:

  • Write select() queries that return objects instead of rows.
  • Explain the difference between objects attached to and detached from a session.

Lesson Outline

HW4 [10 min]

  • HW4 – Vet Clinic in SQLModel: classes, a view, and Faker data
    • Show hw4.dbml in dbdiagram.io; some constraints are only in the notes
    • Step 5 needs today's lab: attached vs. detached objects

SQLModel [20 min]

Lab [45 min]

  • Querying with SQLModel
    • Query the core schema with select(), joins, and relationships
    • Steps 1–5 in class; Step 6 if you have time

Your To-Do List

  • HW4 ← due Monday, Oct 19
  • Last call for GP2 commits!