Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

SQLAlchemy

Python SQL toolkit and object-relational mapper for database abstraction.

Databases, ORMs and clientsPYPI

GitHubWebsite

1. License

License from PyPI license expression.

github.com/sqlalchemy/sqlalchemy

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What SQLAlchemy does

SQLAlchemy splits into a Core SQL toolkit that stands on its own and an ORM layered on top, and its maintainers insist the ORM must not hide the relational database, so every join, subquery and column stays the developer's decision.

SQLAlchemy popularity

80 / 100
Gid Score, #107 overall
105M
downloads a week, pypi
12.3K
GitHub stars
181
agent projects use it
SQLAlchemy: downloads per weekPyPI, sqlalchemy 104,206,510
SQLAlchemy: GitHub starssqlalchemy/sqlalchemy 12,306

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How SQLAlchemy is used

  • SQLAlchemy is a dependency in 181 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (11.2% of the 1,623 Python ones), #5 of 120 in databases, orms and clients.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,623; those are left out of every share on this page.
  • The most used alternative in our scan is DuckDB (26 projects).
  • Projects that use it most often also use FastAPI (76.2%), Uvicorn (76.2%), Pydantic (71.3%).
  • It is more common in projects set up for Roo Code (7.2%) than for OpenAI Codex (1.5%).

By coding agent

94 projects, 2.9%
92 projects, 3.0%
75 projects, 3.1%
12 projects, 2.5%
11 projects, 3.9%
9 projects, 2.7%
8 projects, 7.2%
7 projects, 1.5%

Often used with

In 76.2% of its projects
In 76.2% of its projects
In 71.3% of its projects
In 63.5% of its projects
In 48.6% of its projects
In 47.0% of its projects
In 46.4% of its projects
In 38.7% of its projects

SQLAlchemy in practice

Strengths

Core is a full layer without the ORM

The Core is not just plumbing for the ORM. The README calls it a full database abstraction layer "in its own right". It has its own expression language, schema metadata, connection pooling and custom types.

No "the ORM generated a bad query"

The README says writing ORM queries "uses the same techniques of relational composition you use when writing SQL." The maintainers add that you keep full control over how joins are organized, how subqueries and correlation are used, and which columns are requested.

Literal values stay out of SQL

The maintainers' stated rule is to never render a literal value in a SQL statement. They say bound parameters let query optimizers cache query plans and make SQL injection "a non-issue".

Reflect a schema, then emit CREATE

One step reads an existing database schema into Python metadata objects. The same objects can then generate CREATE statements. The README says both happen in the Core, independent of the ORM.

Watch out for

It will not design the model for you

By the maintainers' own description, the developer makes every decision about the design, structure and naming of both the object model and the schema. SQLAlchemy only provides the means to automate those decisions.

ORM changes persist only on commit()

The README says that with the ORM, nothing goes to permanent storage until <code>commit()</code> is called. It presents this as part of making transactions the norm.

Result iteration held cursors in early 2.1

The 2.1.4 notes fix a regression where iterating a <code>Result</code> directly, or using methods such as <code>Result.scalars()</code>, created reference cycles. These kept the <code>Result</code> and its DBAPI cursor alive until cyclic GC ran. The notes say this came from the 2.1 refactoring of <code>Result</code> into Cython code.

More about SQLAlchemy

Funding
  • GitHub Sponsors: https://github.com/sqlalchemy
  • Patreon: https://patreon.com/zzzeek
  • Tidelift: https://tidelift.com/funding/github/pypi/SQLAlchemy
  • 23 GitHub sponsors

See all

Agent Skills for it
  • sqlalchemy-alembic-expert-best-practices-code-review: SQLAlchemy ORM and Alembic migration best practices for building safe, performant database schemas. This skill should be used when writing,

See all

Packages around it
  • python-dotenv: Loads .env config
  • pydantic: Data validation
  • fastapi: Web API framework
  • uvicorn: ASGI server
  • requests: HTTP client
  • alembic: Schema migrations
More in Databases, ORMs and clients

Alternatives

SQLAlchemy This page

MITGid 80105M/wk

DuckDB

Embedded SQL OLAP database for analytical queries and data processing in Python.

MITGid 5822.6M/wk

Neo4j

Official Python driver for Neo4j graph database with Bolt protocol.

Apache-2.0 AND Python-2.0Gid 543.6M/wk

SQLModel

SQL ORM combining SQLAlchemy with Pydantic for Python databases.

MITGid 667.2M/wk

PyMongo

Official MongoDB Python driver for querying and managing MongoDB databases.

Apache-2.0Gid 6818.5M/wk

Compare SQLAlchemy with another tool

Get started

Install it.

pip install sqlalchemy

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## SQLAlchemy
- Check which line the project pins. The site lists both 2.1.4 and 2.0.54 under "Current Releases", each with its own migration notes and docs. The "Current Documentation" link is for 2.1.
- Never put literal values into SQL statements. Pass them as bound parameters, which the maintainers say lets query plans be cached and makes SQL injection "a non-issue".
- With the ORM, call `commit()` to persist changes. Nothing reaches permanent storage before that.
- If the task does not need an ORM, use the Core expression language instead. The README says: "Don't use an ORM if the problem doesn't need one."
- Express ORM queries with joins, subqueries and correlation in terms of the object model. Literal SQL is available, but the README says it is "virtually never needed".
- On the 2.1 line, use 2.1.4 or later. It fixes `Result` reference cycles introduced by the 2.1 Cython refactor and a connection leak with asyncio drivers.
- On a mapped Declarative class, assign only a `MetaData` object to the `metadata` attribute. Other values trigger a warning that the name should be left reserved.