SQLAlchemy

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

Library
PyPI
v2.0.52
12,093stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
94/100Excellent
Development Activity100
Maintenance100
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
93/100Excellent
Architecture96
Code Quality95
Innovation92
Learning Curve85

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 35 apps in this directory

TypeScript
59%
Other

agenta

Developer Tools · Devops · AI Development

4,489

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript59%
Python39%
Updated today
Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
49%
Other

Airbyte

Developer Tools · Data Engineering

21,916

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
67
Dependency
Built with
Python49%
Kotlin42%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
TypeScript
84%
Apache 2.0

Continue

Developer Tools · AI Development · AI Code Assistants

35,532

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
87
Repo Health
88
Technical
65
Dependency
Built with
TypeScript84%
Updated today
Python
99%
MIT

deepagents

AI Agents · AI Development

27,919

The batteries-included Python agent harness — planning, sub-agents, filesystem, shell, memory, and skills bundled in, built on LangGraph.

View details
88
Repo Health
83
Technical
74
Dependency
Built with
Python99%
Updated today
Python
44%
MIT

/dev/push

Developer Tools · Devops

4,742

Self-hosted, open-source Vercel alternative that deploys Python, Node.js, PHP, and any Docker-compatible app from a Git push, with zero-downtime rollouts and real-time logs.

View details
44
Repo Health
68
Technical
73
Dependency
Built with
Python44%
HTML31%
CSS17%
Updated 5 months ago
Python
57%
MIT

Docglow

Data Engineering

137

A next-generation documentation site generator for dbt Core projects — lineage explorer, health scoring, and full-text search for teams without access to dbt Cloud's built-in docs features.

View details
67
Repo Health
65
Technical
82
Dependency
Built with
Python57%
TypeScript42%
Updated 1 weeks 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

Search