Browse by Topic

Popular

Latest

Latest Python Posts

A diagram showing a database table with columns being added, removed, and renamed using Alembic migration tools.
Python

Python Alembic: Add, Drop, and Rename Columns

Learn how to add, drop, and rename columns with Alembic migrations in Python, including batch operations for SQLite and the key data-loss and locking trade-offs.

AlembicSQLAlchemyDatabase MigrationsSQLite
A visual metaphor of a Python and SQLAlchemy migration pipeline with Alembic autogenerate generating a migration script from a database schema.
Python

Python Alembic Autogenerate with SQLAlchemy

Learn how Alembic autogenerate compares SQLAlchemy models to your database, how to configure `env.py`, and how to review or edit the migrations it generates.

AlembicSQLAlchemyDatabase MigrationsPython
Diagram showing the Alembic migration workflow from revision creation to upgrade and downgrade.
Python

Python Alembic Migrations: Revision, Upgrade, and Downgrade

Learn how to create, apply, and revert Alembic migrations in Python with the revision, upgrade, and downgrade commands.

alembicsqlalchemydatabase migrationsschema management
A visual comparison of SQLAlchemy Core and ORM showing a direct SQL path and an object mapping path to the same database.
Python

Python SQLAlchemy ORM vs Core: Which to Use

python sqlalchemy orm vs core: Compare SQLAlchemy Core and ORM APIs: their design, query construction, performance tradeoffs, and which to pick for your Python project.

SQLAlchemyORMSQLAlchemy CorePython
Illustration showing one parent query branching into many child queries, representing the SQLAlchemy N+1 problem.
Python

Fixing the Python SQLAlchemy N+1 Problem

python sqlalchemy n plus one problem: Learn how the N+1 query problem appears in SQLAlchemy, how to detect it, and how joinedload and selectinload fix it without sacri...

SQLAlchemyORMPerformanceDatabase Queries
Diagram showing database connections being reused through a SQLAlchemy connection pool
Python

Python SQLAlchemy Connection Pooling

Understand SQLAlchemy connection pooling in Python: pool types, capacity settings, preventing stale connections, and diagnosing pool timeouts.

SQLAlchemyConnection PoolingDatabaseWeb Applications
Illustration of an async engine and async session bridging SQLAlchemy's synchronous ORM to an asynchronous database connection.
Python

SQLAlchemy Async Engine and Async Session Explained

python sqlalchemy async engine and async session: Understand how SQLAlchemy's AsyncEngine and AsyncSession wrap the sync ORM, run queries with await, manage transactio...

SQLAlchemyAsync Pythonasyncpgasyncio
Diagram showing SQLAlchemy lazy loading with multiple queries versus eager loading with joinedload and selectinload strategies.
Python

SQLAlchemy Lazy vs Eager Loading: joinedload and selectinload

Understand why SQLAlchemy's default lazy loading causes N+1 queries, and how eager loading with joinedload and selectinload avoids the problem.

SQLAlchemyORMPerformancePython
Diagram showing SQLAlchemy session operations: flush, commit, rollback, and refresh with database state.
Python

SQLAlchemy Transactions: Commit, Rollback, Flush, and Refresh

Understand SQLAlchemy session transactions: flush, commit, rollback, and refresh — how each operation sends SQL, ends transactions, and syncs object state.

SQLAlchemyTransactionsPythonORM
A diagram showing a SQLAlchemy query with a subquery and EXISTS clause, with a raw SQL fragment on the side, representing the choice between ORM and raw SQL.
Python

Python SQLAlchemy Subqueries, EXISTS, and Raw SQL

Learn how to use SQLAlchemy subqueries and EXISTS clauses, and when raw SQL is the better choice, with practical Python examples and tradeoffs.

SQLAlchemysubqueriesEXISTS clauseraw SQL