← All learning paths

Typorithm learning path

SQLAlchemy and Alembic: reliable database work

Own database units of work through SQLAlchemy 2.1 typed models, current autoflush, scalar and row results, deterministic pages, foreign keys, measured loading, aggregates, synchronized DML, savepoints, version conflicts and async Sessions. Review real Alembic revisions, autogenerate candidates, SQLite batch changes, bounded backfills and backup restoration. 18 topics with six substantial sections, gradual tasks, two hints and prepared results. On a computer type and recall focused code; in the app read examples and answer explained questions. Complete programs execute in the downloadable owned SQLite lab, verified with Python 3.13, SQLAlchemy 2.1.8, Alembic 1.20.1 and aiosqlite 0.22.1. No live service or production database is used.

18Focused modules
18Lessons to explore
54Typing drills
SQLAlchemy and Alembic: reliable database work course illustration

Study with a practical destination

Use the linked lessons in order, complete the lab and explain the decisions without the reference. Select the path and depth that match your role.

Your learning path

0 of 18 lessons completed

Saved on this device

01

Module 1 · 1 lessons

Engine, connections and bound SQL parameters

Own a small database transaction and keep SQL structure separate from input values.

0/1 complete
02

Module 2 · 1 lessons

Typed declarative models and database constraints

Distinguish a mapped Python attribute, column nullability and a constraint enforced by the database.

0/1 complete
03

Module 3 · 1 lessons

Session state, autoflush and durability in 2.1

Observe an inserted row inside a transaction without confusing flush with a durable commit.

0/1 complete
04

Module 4 · 1 lessons

Rows, scalar columns and ORM result shapes

Choose the result API from the selected expressions rather than assuming every query returns model objects.

0/1 complete
05

Module 5 · 1 lessons

Filtered and deterministic bounded pages

Combine a precise population predicate with a total order and a validated result limit.

0/1 complete
06

Module 6 · 1 lessons

Foreign keys, relationships and parent ownership

Verify relational integrity at the database boundary instead of mistaking an ORM link for an enforced constraint.

0/1 complete
07

Module 7 · 1 lessons

Loading relationships without an N+1 surprise

Preserve the parent population while measuring lazy, select-in and joined collection loading.

0/1 complete
08

Module 8 · 1 lessons

Outer joins and honest aggregate populations

Count real child identities while retaining parents that have no matching child rows.

0/1 complete
09

Module 9 · 1 lessons

Set-based updates and the identity map

Keep loaded ORM objects consistent with an explicit bulk statement and verify the database separately.

0/1 complete
10

Module 10 · 1 lessons

Savepoints and recovery from a failed flush

Reject a duplicate insert while keeping valid work in the surrounding transaction.

0/1 complete
11

Module 11 · 1 lessons

Optimistic version checks and deliberate retries

Reject an update based on an old mapped version and reread current state before applying a reviewed merge policy.

0/1 complete
12

Module 12 · 1 lessons

Async Session ownership and implicit IO

Give independent tasks their own Sessions and avoid unawaited reloads of expired ORM attributes.

0/1 complete
13

Module 13 · 1 lessons

Schema bootstrap is not a migration history

Observe what create_all leaves unchanged and apply one explicit additive operation to an existing table.

0/1 complete
14

Module 14 · 1 lessons

Revision chains, upgrade, downgrade and stamp

Run an actual two-revision Alembic environment and compare schema execution with merely marking a version.

0/1 complete
15

Module 15 · 1 lessons

Autogenerate candidates require a review

Compare proposed metadata with the real schema, apply a reviewed change and check for a remaining diff.

0/1 complete
16

Module 16 · 1 lessons

SQLite batch changes that preserve rows and constraints

Backfill existing values before tightening nullability and verify the recreated table’s constraints and indexes.

0/1 complete
17

Module 17 · 1 lessons

Expand, bounded backfill and contract tightening

Walk stable IDs in small batches before making a newly populated column non-nullable.

0/1 complete
18

Module 18 · 1 lessons

Capstone: migrate, inspect and restore an owned database

Verify both revision history and data after a real SQLite backup and restoration.

0/1 complete