SQLAlchemy

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

Library
PyPI
v2.1.6
12,262 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
94 /100 Excellent
Development Activity 100
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

TypeScript
26%
AGPL 3.0

Omnivore

Bookmarks Archiving · Knowledge Management · Note Taking

16,356

Self-hosted read-it-later platform with highlights, newsletters, PDFs, and seamless Obsidian and Logseq integration.

View details
90
Repo Health
74
Technical
65
Dependency
Built with
TypeScript 26%
JavaScript 24%
HTML 20%
Updated 1 weeks ago
Python
38%
Other

Open WebUI

AI Agents · AI Assistants

156,607

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
92
Repo Health
75
Technical
66
Dependency
Built with
Python 38%
Svelte 35%
JavaScript 19%
Updated 6 days ago
TypeScript
92%
Other

OpenHands

AI Code Assistants · AI Development

91,695

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 92%
Updated 1 weeks ago
TypeScript
54%
Other

OpenReplay

Analytics

13,042

Self-hosted session replay and product analytics suite that lets you see exactly what users do on your web app — without sending data to third parties.

View details
91
Repo Health
77
Technical
66
Dependency
Built with
TypeScript 54%
Go 13%
Updated 1 weeks ago
Python
68%
Apache 2.0

otari

AI Development · Developer Tools

733

A self-hosted, OpenAI-compatible LLM gateway that puts one endpoint in front of 40+ providers, with virtual API keys, per-user budgets enforced before spend, and full usage tracking.

View details
82
Repo Health
88
Technical
74
Dependency
Built with
Python 68%
TypeScript 31%
Updated 1 weeks ago
TypeScript
58%
MIT

pad.ws

Collaboration · Design Tools

4,206

A browser-based whiteboard that doubles as a full development environment, letting you draw and code in the same canvas.

View details
37
Repo Health
61
Technical
78
Dependency
Built with
TypeScript 58%
Python 31%
SCSS 10%
Updated 1 years ago
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,976

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
Python 49%
TypeScript 43%
Updated 6 days ago
Python
62%
Apache 2.0

Polar

Developer Tools · Ecommerce · Invoicing Finance

10,410

Open source payments infrastructure that turns software into a business — subscriptions, usage-based billing, digital products, and merchant-of-record compliance in one platform.

View details
90
Repo Health
82
Technical
66
Dependency
Built with
Python 62%
TypeScript 31%
Updated 1 weeks ago
Python
87%
Apache 2.0

PrivateGPT

AI Development

57,611

The open-source API layer that turns local LLMs into production private AI applications with full Claude API compatibility

View details
88
Repo Health
83
Technical
70
Dependency
Built with
Python 87%
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