SQLAlchemy-Utils

A grab-bag of extra column types, aggregates, and utility functions for SQLAlchemy models.

Library
PyPI
v0.42.1
1,345 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
74 /100 Good
Development Activity 56
Maintenance 64
Community 88
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
69 /100 Good
Architecture 72
Code Quality 78
Innovation 60
Learning Curve 65

SQLAlchemy-Utils extends SQLAlchemy with a large collection of custom column types (email, phone number, URL, currency, color, IP address, encrypted, JSON, UUID, and more), model helper functions (aggregated columns, generic relationships, view support), and standalone utilities for common patterns that SQLAlchemy’s core doesn’t cover out of the box, such as creating/dropping test databases, force-cascading deletes, and coercing scalar values. It’s built on top of SQLAlchemy 2.0+ and is widely used as a companion library rather than a replacement for the ORM itself.

What You Get

  • Dozens of custom SQLAlchemy column types: EmailType, PhoneNumberType, URLType, ColorType, CurrencyType, IPAddressType, EncryptedType, JSONType, UUIDType, PasswordType, and more
  • Aggregated column support that keeps a denormalized aggregate (count, sum, etc.) in sync with related rows
  • Utility functions for database lifecycle in tests: create_database(), drop_database(), database_exists()
  • Generic relationship and view helpers for modeling polymorphic associations and SQL views as ORM entities

Common Use Cases

  • Storing and validating structured data (emails, phone numbers, currencies, colors) directly as typed SQLAlchemy columns instead of plain strings
  • Spinning up and tearing down throwaway test databases in a pytest suite via create_database()/drop_database()
  • Maintaining a denormalized aggregate column (e.g. a running comment count) automatically as related rows change
  • Encrypting sensitive column values at rest with EncryptedType while keeping normal ORM query ergonomics

Under The Hood

Architecture: The library is a flat collection of independent modules rather than a single cohesive subsystem: sqlalchemy_utils/types/*.py each define one custom column type by subclassing SQLAlchemy’s TypeDecorator and implementing process_bind_param/process_result_value, while sqlalchemy_utils/functions/ holds standalone helpers (database creation, cascading deletes) and aggregates.py/generic.py/observer.py/view.py add SQLAlchemy event-listener-based behaviors (e.g. aggregates.py hooks into the ORM’s mapper/session events to recompute denormalized columns on flush). Tech Stack: Pure Python 3.10+ built on SQLAlchemy>=2.0 as its only hard dependency, with a long tail of optional extras (Babel, arrow, pendulum, phonenumbers, passlib, colour, intervals) gated behind pip extras so users only pull in what a given type needs. Code Quality: A substantial tests/ directory (110+ files) mirrors the module layout closely, with dedicated test modules per column type and per utility function, run against multiple real database backends (psycopg2, pymysql, pyodbc) rather than mocks, reflecting the library’s cross-dialect compatibility goals. API Design: Types and functions are designed as drop-in replacements for stock SQLAlchemy Column type arguments (e.g. Column(EmailType) instead of Column(String)), so adopting one feature requires no restructuring of existing models, though the sheer breadth of the API surface (dozens of types/functions) means discoverability relies heavily on the documentation site.

Used by 7 apps in this directory

TypeScript
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

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
TypeScript 56%
Python 39%
Updated 5 days ago
Python
89%
Apache 2.0

Apache Airflow

Data Engineering

46,995

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
64
Dependency
Built with
Python 89%
Updated 4 days ago
Python
64%
Other

Keep

Automation · Devops · Monitoring

12,359

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
89
Repo Health
79
Technical
66
Dependency
Built with
Python 64%
TypeScript 36%
Updated 1 weeks ago
Python
86%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,541

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
82
Repo Health
75
Technical
66
Dependency
Built with
Python 86%
HTML 14%
Updated 1 weeks ago
Python
51%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,301

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
90
Repo Health
77
Technical
66
Dependency
Built with
Python 51%
TypeScript 48%
Updated 5 days ago
Python
65%
Apache 2.0

Polar

Developer Tools · Ecommerce · Invoicing Finance

10,293

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 65%
TypeScript 28%
Updated 4 days 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 4 days 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