SQLAlchemy-Utils

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

Library
PyPI
v0.43.0
1,346 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
73 /100 Good
Development Activity 68
Maintenance 48
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
55%
Other

agenta

AI Development · Developer Tools · Devops

4,856

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

View details
91
Repo Health
77
Technical
66
Dependency
Built with
TypeScript 55%
Python 40%
Updated today
Python
87%
Apache 2.0

Apache Airflow

Data Engineering

47,268

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 87%
Updated today
Python
64%
Other

Keep

Automation · Devops · Monitoring

12,433

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
88
Repo Health
79
Technical
66
Dependency
Built with
Python 64%
TypeScript 36%
Updated 2 days ago
Python
94%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,755

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

View details
83
Repo Health
75
Technical
66
Dependency
Built with
Python 94%
Updated today
Python
53%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,413

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
65
Dependency
Built with
Python 53%
TypeScript 45%
Updated today
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 yesterday
Python
45%
Other

Redash

Analytics · Data Engineering

28,849

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
91
Repo Health
74
Technical
61
Dependency
Built with
Python 45%
JavaScript 29%
TypeScript 19%
Updated 2 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