SQLAlchemy

The Python SQL toolkit and Object Relational Mapper that gives developers the full power and flexibility of SQL.

Library
PyPI
v2.1.1
12,189 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
93 /100 Excellent
Development Activity 96
Maintenance 100
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
93 /100 Excellent
Architecture 96
Code Quality 95
Innovation 92
Learning Curve 85

SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. It provides a comprehensive suite of enterprise-grade persistence patterns built on the identity map, unit of work, and data mapper models, layered on top of a standalone Core that exposes a full Python-based SQL expression language, schema metadata, connection pooling, and typed result handling.

The ORM and Core are cleanly separated so you can adopt either level independently, and a broad dialect system supports PostgreSQL, MySQL/MariaDB, SQLite, Oracle, and SQL Server through synchronous and asyncio drivers alike.

What You Get

  • A production-grade ORM implementing the identity map, unit of work, and data mapper patterns with declarative model configuration
  • A standalone Core SQL expression language for building database-agnostic queries that render to native SQL
  • Connection pooling, transaction management, and a typed result/Row API shared across the whole toolkit
  • A dialect system covering PostgreSQL, MySQL/MariaDB, SQLite, Oracle, and SQL Server with both sync and asyncio support
  • Schema reflection and DDL generation to introspect existing databases or emit CREATE statements from Python metadata

Common Use Cases

  • Mapping domain models to relational tables in web and backend applications
  • Building complex, composable SQL queries programmatically without writing raw string SQL
  • Powering the data layer of frameworks and tools such as Flask, FastAPI, and Alembic migrations
  • Reflecting and manipulating existing database schemas across multiple database backends
  • Running async database access with asyncio drivers for high-concurrency services

Under The Hood

Architecture SQLAlchemy is organized as two cooperating layers under lib/sqlalchemy. The Core (sql/, engine/, pool/) provides an SQL expression language whose constructs in sql/elements.py, sql/selectable.py, and sql/dml.py are compiled to backend SQL by sql/compiler.py, then executed through the engine/ Connection and Engine against pooled DBAPI connections. The ORM (orm/) builds on Core: orm/mapper.py maps classes to tables, orm/session.py implements the unit-of-work that tracks changes via the identity map and flushes them through orm/persistence.py, while orm/query.py and the 2.x select() path translate object-level queries into Core statements. Backend differences are isolated in dialects/ (postgresql, mysql, sqlite, oracle, mssql), each adapting compilation and typing to a specific database and driver.

Tech Stack The library targets Python 3.10+ with a single hard runtime dependency, typing-extensions, and an optional greenlet dependency enabling the asyncio API. Performance-critical helpers are written in Cython and compiled at build time (via setuptools and pyproject.toml build config), falling back to pure Python where unavailable. Optional driver extras pull in psycopg, asyncpg, mysqlclient, oracledb, pyodbc, and others per backend, and the package ships a py.typed marker for full static typing.

Code Quality The codebase is mature and rigorously tested, with roughly 325 test modules under test/ plus a purpose-built testing harness inside lib/sqlalchemy/testing used across backends and by third-party dialects. Static typing is thorough with PEP 484 annotations throughout, and quality gates are enforced via a pre-commit configuration and CI across many Python versions and databases. Naming and module boundaries are consistent and deliberate, reflecting two decades of maintenance.

API Design SQLAlchemy exposes an ergonomic, layered public API: high-level declarative ORM models with Mapped and mapped_column, a unified 2.0 select() query style shared between Core and ORM, and drop-into-Core access whenever explicit SQL control is needed. The surface is large because it is comprehensive, which contributes to a steeper learning curve, but it is extensively documented, richly exemplified in the examples/ directory, and consistent enough that patterns learned at one layer transfer to the others.

Used by 44 apps in this directory

JavaScript
50%
AGPL 3.0

QRev

AI Agents · CRM

363

Open source AI-first sales platform that replaces Salesforce with autonomous agents handling prospecting, outreach, and lead management at scale.

View details
38
Repo Health
68
Technical
63
Dependency
Built with
JavaScript 50%
Python 28%
TypeScript 14%
Updated 8 months ago
Python
99%
Apache 2.0

Rasa Open Source

AI Assistants · AI Development · Voice AI

21,332

Rasa Open Source is a Python machine learning framework for building contextual, multi-turn chatbots and voice assistants that understand natural language and maintain conversation state.

View details
64
Repo Health
78
Technical
63
Dependency
Built with
Python 99%
Updated 2 months ago
Python
46%
Other

Redash

Analytics · Data Engineering

28,817

Redash lets anyone connect to 35+ SQL and NoSQL data sources, write a query in the browser, and turn the result into a shared dashboard — no separate BI suite required.

View details
92
Repo Health
74
Technical
60
Dependency
Built with
Python 46%
JavaScript 30%
TypeScript 17%
Updated 1 weeks ago
Python
76%
Apache 2.0

Second Me

AI Assistants · Productivity

15,690

Train a locally hosted AI twin on your own memories—then connect it to the world through a decentralized identity network.

View details
41
Repo Health
75
Technical
67
Dependency
Built with
Python 76%
TypeScript 19%
Updated 1 years ago
TypeScript
50%
Other

SigNoz

Analytics · Monitoring

32,224

Self-host your entire observability stack — logs, metrics, traces, and LLM monitoring — in one OpenTelemetry-native platform, without the Datadog bill.

View details
92
Repo Health
83
Technical
67
Dependency
Built with
TypeScript 50%
Go 38%
Updated 1 weeks ago
Python
78%
AGPL 3.0

Skyvern

AI Agents · Automation

23,088

Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Python 78%
TypeScript 20%
Updated 1 weeks ago
Python
70%
AGPL 3.0

Tracecat

AI Agents · Automation · Security

3,816

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

View details
89
Repo Health
88
Technical
66
Dependency
Built with
Python 70%
TypeScript 28%
Updated 1 weeks ago
TypeScript
53%
MIT

Voicebox

AI Development · Productivity · Voice AI

55,864

Clone voices, dictate anywhere, and give AI agents your voice — all locally.

View details
79
Repo Health
76
Technical
68
Dependency
Built with
TypeScript 53%
Python 35%
Updated 2 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers