pkgdocs/compare/alembic vs sqlalchemy

Comparing

Python

alembic

Database migration tool for SQLAlchemy — tracks schema changes as versioned scripts.

3.8M/ wk
v1.13.2
vs
Python

sqlalchemy

Database Abstraction Library

0/ wk
v2.0.48
Metricalembicsqlalchemy
EcosystemPythonPython
DifficultyIntermediateBeginner ✓
Weekly downloads3.8M↑0
Latest versionv1.13.2v2.0.48
Recipes2↑1

Tags

alembic only

migrationssqlalchemyschema

Shared

databaseorm

sqlalchemy only

sqlpostgresqlmysqlfront-ends

When to use each

alembic

Any production SQLAlchemy app. Column additions/renames, index creation, constraint changes, data backfills as part of schema migrations.

sqlalchemy

Use SQLAlchemy in any Python application that talks to a relational database — web apps, data pipelines, ETL scripts. It supports PostgreSQL, MySQL, SQLite, and Oracle, so the same code runs everywhere. It's the standard ORM in the Python ecosystem, with integrations for Flask, FastAPI, and most web frameworks.

When to skip each

alembic

Non-SQLAlchemy databases (use Flyway, Liquibase, or Django migrations). Throwaway dev DBs where you can afford to drop and recreate.

sqlalchemy

SQLAlchemy's full ORM is overkill for simple read-only queries or scripts that just need to run a few SQL statements. For those cases, use the database's driver directly (psycopg2, sqlite3) or a lightweight query builder like databases.

Sample recipes

alembic

  • Set up Alembic in a new project
  • Auto-generate and apply a migration

sqlalchemy

  • Install sqlalchemy