SQLAlchemy 2.0 - The One-Point-Four-Ening 2021
summary
SQLAlchemy 1.4 implements the planned SQLAlchemy 2.0 architecture: it is Python 3 only with a new Core/ORM alignment and 1.4 serving as the transitional caterpillar. Engine usage now requires explicit connect/begin (no more engine.execute or session.query); the Result object is unified across Core and ORM and SQL compilation is largely cached. Sessions use SessionMaker.begin as a context manager, registry/declarative mapping and the unit‑of‑work/identity map persist objects, and eager loaders (selectinload, joinedload, contains_eager) solve N+1. New runtime warnings detect cartesian products; async support uses asyncpg and aiomysql.
AI-written summary · about
chapters (49)
- 0:00Introduction to SQLAlchemy 2.0
- 1:05SQLAlchemy 1.4 as transition to 2.0
- 1:47Core concepts and SQL automation
- 3:13Philosophy behind SQLAlchemy
- 4:56SQLAlchemy onion diagram explained
- 10:46Python 3 only and async I/O support
- 11:28Major changes in SQLAlchemy 2.0
- 14:11Engine and connection basics
- 20:14Running Python scripts with SQLAlchemy
- 21:18Creating and connecting to an engine
- 24:05Executing textual SQL queries
- 27:54Connection pooling and closing
- 30:22Transaction management in 2.0
- 36:39Database metadata and reflection
- 39:10Creating table metadata
- 42:56Generating DDL from metadata
- 46:24Reflecting existing databases
- 48:30Alembic migrations overview
- 49:13SQL expression language introduction
- 51:59Building SQL statements in Python
- 54:04Column comparisons and binary expressions
- 57:14Bound parameters and security
- 1:01:42Insert and update statements
- 1:04:11Joins in SQL Core
- 1:11:13One-to-many relationships
- 1:14:22Cartesian product warnings
- 1:15:51Explicit joins with join and join_from
- 1:18:38Table aliases and derived tables
- 1:23:11Subqueries and CTEs
- 1:30:58Correlated subqueries
- 1:34:54When to use text queries
- 1:35:56Object relational mapping basics
- 1:44:40ORM mapping styles
- 1:49:15Session and session maker
- 1:51:00Adding objects to session
- 1:54:12Auto-flushing and querying
- 1:58:28Committing transactions
- 2:05:14Rolling back changes
- 2:07:17Querying with ORM entities
- 2:16:43Basic ORM queries
- 2:17:46Advanced ORM with relationships
- 2:20:37Creating database schema for ORM
- 2:23:25Unit of work and cascading
- 2:29:43Joins with ORM entities
- 2:32:53ORM aliases and relationships
- 2:35:21Subqueries and CTEs in ORM
- 2:36:27Eager loading strategies
- 2:37:07N+1 problem and eager loading
- 2:41:19Join load vs selectin load
