Skip to main content
Loading page…
Python Mastery
Chapter 30
Lesson 2 of 4
ORM Models & Sessions
Contents
Notes
Tutor
Concept
The ORM Mental Model: Unit of Work
Loading activity…
Previous
1 / 8
Continue
Contents
Notes
Discussion
Tutor
30 min
8 activities
0 of 8 done
In this lesson
1
The ORM Mental Model: Unit of Work
2
Full CRUD with Session
3
Session State Machine
4
session.flush() vs session.commit()
5
CRUD: Create and Count
6
Session & Identity Map Quiz
7
Explain the Unit of Work Pattern
8
Always Use session as a Context Manager
Objectives
Learner can define mapped model classes using SQLAlchemy 2.0 DeclarativeBase and Mapped[]
Learner can perform CRUD operations using the Session and its unit-of-work pattern
Learner can explain the identity map and how Session tracks object state
Learner can use Session.get(), Session.execute(select()), and filter conditions correctly
Chapter 30 · Database Mastery with SQLAlchemy
SQLAlchemy Core & the Engine
ORM Models & Sessions
Relationships & Query Performance
Schema Migrations with Alembic
Previous: SQLAlchemy Core & the Engine
Next: Relationships & Query Performance