Updated

SQLAlchemy

Python SQL toolkit and ORM, the standard way Python apps outside Django talk to relational databases.

221 open-source projects declare SQLAlchemy in their code; 1 maker's product we track uses it. What makers like most: Its data-mapper and query-object style makes SQL reusable and composable without hiding the database, from simple selects to multi-join aggregates. Their most common complaint: It feels complicated, and it is hard to see what SQL it actually runs or spot hidden queries in loops.

Open sourceSelf-hostableFree tier

Profile checked

Ask your AI about this, with this page as the source:ChatGPT ↗Claude ↗Perplexity ↗

How makers use SQLAlchemy

Makers' products we track use SQLAlchemy for database access & ORMs (1).

What SQLAlchemy is used for

Database Access & ORMs · SQL-shaped ORM →Python backends (FastAPI, Flask, scripts) that want an ORM or a SQL toolkit over any relational database.Trade-off: A large API with two styles (ORM and Core); migrations come from a separate tool, Alembic.
Prisma37Drizzle ORM12SQLAlchemy1Kysely0TypeORM0Makers' products on each, for database access & ORMs

SQLAlchemy vs the alternatives makers chose

For database access & ORMs, 1 of the 50 makers' products we know the choice of picked SQLAlchemy (2%), behind Prisma (74%).

OptionMakers' productsOpen source
Prisma37 74%Yes
Drizzle ORM12 24%Yes
SQLAlchemy1 2%Yes

For database access & ORMs: how many of the 50 makers' products we know the database access & ORMs of chose each option.

When to use SQLAlchemy, and when not

Pick SQLAlchemy if

Something else fits better if

  • You want one schema file that generates types, migrations and a readable query API: Prisma.
  • You deploy to serverless or edge functions and want queries that read like SQL, fully typed: Drizzle ORM.
  • You already write SQL comfortably and only want types around it, no schema layer: Kysely.
From each decision's guide, written from what makers' products chose and why.

SQLAlchemy is the database library most Python web apps use when they are not built on Django. It lets Python code define tables, build queries and map rows to objects across many databases without hand-built SQL strings.

More about SQLAlchemy

It has two layers. Core handles engines, connection pooling, dialects and the SQL Expression Language, a way of composing SQL statements from Python objects and running them in a transaction. The ORM sits on top. You map classes to tables, and a Session tracks changes to those objects and turns them into INSERT, UPDATE and DELETE statements when you commit, a pattern called "unit of work". You can use Core alone or both together. Version 2.1 is the current release series and requires Python 3.11 or newer.

What a team gets: built-in dialects for PostgreSQL, MySQL and MariaDB, SQLite, Oracle and SQL Server, with external dialects for CockroachDB, ClickHouse, Redshift, Databricks and others; asyncio support for both Core and the ORM through async drivers such as asyncpg and aiosqlite; and fine control over how relationships load. Schema migrations are handled by Alembic, a separate tool from the same authors that can autogenerate migration scripts from your models. It is an MIT-licensed library that runs inside your app.

Limits: SQLAlchemy is large, and its ORM rewards learning how sessions, loading strategies and transactions interact. In async code, lazy-loaded relationships must be avoided or loaded explicitly, since attribute access cannot quietly run a query. Alembic's autogenerate needs manual review and cannot detect renames.

How SQLAlchemy itself is built

4 tools, from its own code, website and Product Hunt page.

SQLAlchemy pros and cons

What makers like most: Its data-mapper and query-object style makes SQL reusable and composable without hiding the database, from simple selects to multi-join aggregates. Their most common complaint: It feels complicated, and it is hard to see what SQL it actually runs or spot hidden queries in loops.

Pros

  • Its data-mapper and query-object style makes SQL reusable and composable without hiding the database, from simple selects to multi-join aggregates. HNHN 2HN 3
  • Mapping rows to objects removes serialization boilerplate and makes schema changes less painful than hand-written SQL. HNHN 2HN 3
  • SQLAlchemy Core works as a plain query builder when you do not want the ORM layer. HNHN 2
  • Paired with Alembic, it gives model-driven migrations without pulling in all of Django. HNHN 2

Cons and watch-outs

  • It feels complicated, and it is hard to see what SQL it actually runs or spot hidden queries in loops. HNHN 2HN 3HN 4
  • Operator-overloaded expressions and sprawling signatures confuse type checkers and cause footguns like comparisons that are always truthy. HNHN 2HN 3
  • Lazy-loaded relationships make N+1 query problems easy to create. HNHN 2
  • Its client-side pool conflicts with PgBouncer, reusing killed connections and clashing with prepared statements. HNHN 2

Themes that recur in makers' words and Hacker News comments, each linked to what it summarises.

What Hacker News says about SQLAlchemy

On Hacker News, 23% of comments about SQLAlchemy recommend it and 14% criticize it: net praise +9%, the least liked of 4 tools HN discusses for database access & ORMs.

By year

YearComments choosing it, per monthNet praise
20231.8+16%
20241.2−10%
20253.7+25%
2026 (8 mo)2.1−9%

In their words

  • “Every time I use an ORM (SQLAlchemy mostly, the one mentioned in the article) I am 100% sure what SQL” HN, Jul 2026
  • “SQLAlchemy has its own frozendict which we've had in use for many years” HN, Dec 2025
  • “it's much easier to reason about than SQLAlchemy's event system” HN, Mar 2026

Hacker News comments January 2023 to August 2026 that name SQLAlchemy in a sentence like "I use" or "we moved to", Claude read a sample of 100 and the counts scale it to all of them; net praise is comments recommending it minus comments criticizing it, as a share of all comments about it. How it's counted, and how HN compares with makers.

Reliability and open issues

The most wanted open issue on GitHub has 35 👍.

Most wanted on GitHub

Open on 2026-10-04 in sqlalchemy/sqlalchemy, with activity in the last year — issues and feature requests by 👍.

Who uses it

1 makers' products, each linked to the source that shows it, and 221 open-source projects that declare it in their code.

Job posting 1Declared in code 221How evidence is collected →
aci
aciACI.dev is the open source tool-calling platform that hooks up 600+ tools into any agent…Database Access & ORMsIn its code · source ↗
Agno
AgnoOpen-source Python agent framework and runtime (AgentOS) that you run in your own cloud,…Database Access & ORMsIn its code · source ↗
Aix-DB
Aix-DBAix-DB 基于 LangChain/LangGraph 框架,结合 MCP Skills 多智能体协作架构,实现自然语言到数据洞察的端到端转换。Database Access & ORMsIn its code · source ↗
camel
camel🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agent…Database Access & ORMsIn its code · source ↗
LangBot
LangBotProduction-grade platform for building agentic IM bots - 生产级多平台智能机器人开发平台/ Agent、知识库编排、插件…Database Access & ORMsIn its code · source ↗
Mem0
Mem0Memory layer for agents and apps that extracts facts from conversations and retrieves th…Database Access & ORMsIn its code · source ↗
omi
omiOpen-source AI wearable with mobile and desktop apps that records conversations and meet…Database Access & ORMsIn its code · source ↗

Open source: a project that declares SQLAlchemy as a dependency in its public code — verifiable, but not necessarily a live product.

What its projects tell coding agents

What open-source projects' AGENTS.md and CLAUDE.md files say about SQLAlchemy, in our words — from the 20 files that name it:

79 of the 146 open-source products built with SQLAlchemy that were worked on in the last 180 days keep instruction files for coding agents — 54%, against 53% of all the projects we read. AGENTS.md is in 60, CLAUDE.md in 57.

1,033words in the median file
uvthe package manager most named, in 37 of 73 files
78%say how to test a change
Named more in these files than in other projects' — in how many of the 73:
What AGENTS.md files say about other tools →What open-source products tell their coding agents →

Alternatives to SQLAlchemy

All alternatives by situation →

Questions makers ask about SQLAlchemy

What is SQLAlchemy used for?

Python SQL toolkit and ORM, the standard way Python apps outside Django talk to relational databases. Makers' products we track use it for database access & ORMs (1).

What are the pros and cons of SQLAlchemy?

Pros makers name: Its data-mapper and query-object style makes SQL reusable and composable without hiding the database, from simple selects to multi-join aggregates. Mapping rows to objects removes serialization boilerplate and makes schema changes less painful than hand-written SQL. SQLAlchemy Core works as a plain query builder when you do not want the ORM layer. Cons: It feels complicated, and it is hard to see what SQL it actually runs or spot hidden queries in loops. Operator-overloaded expressions and sprawling signatures confuse type checkers and cause footguns like comparisons that are always truthy. Lazy-loaded relationships make N+1 query problems easy to create.

What are the alternatives to SQLAlchemy?

For database access & ORMs, the other options makers' products we track chose most are Prisma (37), Drizzle ORM (12). Open source or self-hostable among them: Prisma, Drizzle ORM. Each alternative, with the situation it fits, is on the SQLAlchemy alternatives page.

When should you use SQLAlchemy?

Your backend is Python and not Django (database access & ORMs). Something else fits better if: you want one schema file that generates types, migrations and a readable query API, pick Prisma; you deploy to serverless or edge functions and want queries that read like SQL, fully typed, pick Drizzle ORM.

Which databases does SQLAlchemy support?

Included dialects cover PostgreSQL, MySQL and MariaDB, SQLite, Oracle and Microsoft SQL Server, each needing its DBAPI driver installed. Maintained external dialects add databases such as CockroachDB, ClickHouse, Amazon Redshift and Databricks. source ↗

Which Python versions does it need?

SQLAlchemy 2.1 targets Python 3.11 and above. Asyncio support is an extra; install sqlalchemy[asyncio] to get the greenlet dependency, which 2.1 no longer installs by default. source ↗

Do I have to use the ORM?

No. Core and its SQL Expression Language work on their own, building SQL from composable Python objects and running it against the database. The ORM is an optional layer that adds object mapping and unit-of-work persistence. source ↗

Can I use it with asyncio (FastAPI and similar)?

Yes. Both Core and the ORM support asyncio through async-compatible dialects such as asyncpg and aiosqlite, but your code must avoid implicit IO, such as lazy-loaded relationships, using eager loading or the AsyncAttrs mixin instead. source ↗

How do I handle schema migrations?

With Alembic, a lightweight migration tool built for SQLAlchemy. Its autogenerate feature drafts migrations from your models, but the scripts always need review; it cannot detect table or column renames (they appear as drop and add) or unnamed constraints. source ↗

Is SQLAlchemy free?

Yes — it is free, open-source software.

Is SQLAlchemy open source or self-hostable?

Open source, and you can self-host it. source ↗

Can AI coding agents work with SQLAlchemy?

No llms.txt, official MCP server or CLI found yet.

Who uses SQLAlchemy?

1 makers' products we track, each with a source, and 221 open-source projects declare it in their code. source ↗