SQLAlchemy-Utils

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
77/100Good
Development Activity68
Maintenance64
Community88
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
69/100Good
Architecture72
Code Quality78
Innovation60
Learning Curve65

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
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
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
63%
Other

Keep

Devops · Automation · Monitoring

12,224

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
91
Repo Health
79
Technical
67
Dependency
Built with
Python63%
TypeScript36%
Updated today
Python
83%
Apache 2.0

knowhere

AI Development · Developer Tools

2,515

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

View details
83
Repo Health
75
Technical
70
Dependency
Built with
Python83%
HTML16%
Updated today
Python
51%
AGPL 3.0

LearnHouse

Learning Management · CMS

2,178

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

View details
89
Repo Health
77
Technical
67
Dependency
Built with
Python51%
TypeScript48%
Updated 3 days ago
Python
67%
Apache 2.0

Polar

Ecommerce · Developer Tools · Invoicing Finance

10,199

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
71
Dependency
Built with
Python67%
TypeScript26%
Updated today
Python
45%
Other

Redash

Analytics · Data Engineering

28,754

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
85
Repo Health
74
Technical
61
Dependency
Built with
Python45%
JavaScript31%
TypeScript17%
Updated yesterday

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