sqlalchemy-mixins
Active Record, Django-like queries, nested eager load and beauty __repr__ for SQLAlchemy
What it is and what it does
sqlalchemy-mixins adds Active Record and Django-inspired ORM patterns on top of SQLAlchemy's Data Mapper architecture. Instead of writing session.query(User).filter(...).all(), you call User.where(...).all() directly on the model class. The package provides mixins you inherit into your model base class to gain CRUD shortcuts (create, update, delete, find), query helpers (all, first, where), eager-load control (with_joined, with_subquery), and automatic timestamp tracking.
It's designed to feel familiar to developers coming from Django or Eloquent ORM while remaining framework-agnostic. The library handles the session plumbing internally once you set it up, reducing boilerplate. It covers serialization to dict, nested eager loading with joinedload and subqueryload, and filtering by relations using Django-style double-underscore syntax.
Use it for:
- Migrate from Django ORM to SQLAlchemy while keeping familiar query syntax and reducing code rewrite effort.
- Build Flask or FastAPI apps where you want Active Record convenience without a full framework ORM.
- Reduce boilerplate in SQLAlchemy projects by replacing repetitive session.query() chains with model methods.
- Implement eager loading strategies (nested joins, subqueries) with cleaner syntax than raw SQLAlchemy.
- Add automatic created_at and updated_at timestamp tracking to models without manual column management.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Active Record-style mixins for SQLAlchemy ORM, enabling Django-like query syntax, eager loading, and CRUD operations on model classes.
Yes, if you are starting a new SQLAlchemy project and prefer Active Record patterns or migrating from Django. No, if you need active maintenance—the dormant status (last release 2023-08-29) means security patches and compatibility updates are unlikely. Suitable for stable, low-change codebases; risky for projects requiring ongoing support.
Install
sqlalchemy-mixins on PyPI
pip
pip install sqlalchemy-mixinsuv
uv add sqlalchemy-mixinspoetry
poetry add sqlalchemy-mixinsInstalling sqlalchemy-mixins
Before you install
Low friction install with three straightforward runtime dependencies. Maintenance is dormant—last release was 2023-08-29 and last commit 2024-09-08—so expect no active bug fixes or feature updates.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install sqlalchemy-mixins
from sqlalchemy_mixins import AllFeaturesMixin
class User(Base, AllFeaturesMixin):
pass
BaseModel.set_session(session)
bob = User.create(name='Bob')
user = User.find(1)
User.all()
Requires SQLAlchemy session to be initialized via set_session() and autocommit must be enabled on the session for CRUD operations to work.
Verify before relying
- Compatibility with current SQLAlchemy versions beyond what classifiers claim
- Whether dormant status means the package is stable or abandoned for practical purposes
- Performance characteristics compared to raw SQLAlchemy queries in production workloads
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — SQLAlchemy, six, typing |
| Maintenance | dormant — 1,081 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 410,284/month — #6,865 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sqlalchemy_mixins-2.0.5-py3-none-any.whl
Keywords: sqlalchemy, active record, activerecord, orm, django-like, django, eager load, eagerload, repr, __repr__, mysql, postgresql, pymysql, sqlite
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
Flask-SQLAlchemyFlask-SQLAlchemy integrates SQLAlchemy database…
permissive · top 1,000 on PyPI
mixerMixer generates test data and model instances…
permissive · top 15,000 on PyPI
odata-queryParses OData v4 filter strings and transpiles…
permissive · top 15,000 on PyPI
sqlalchemy-mateSimplifies SQLAlchemy code with helper…
permissive · top 5,000 on PyPI
zope.sqlalchemyIntegrates SQLAlchemy sessions with Zope's…
unclear · top 15,000 on PyPI
SQLAlchemySQLAlchemy is a Python SQL toolkit and Object…
permissive · top 100 on PyPI
nplusoneDetects n+1 query problems in Python ORMs…
unclear · top 15,000 on PyPI
sqlalchemy-filtersAdds filtering, sorting, and pagination…
permissive · top 15,000 on PyPI
advanced-alchemyAdvanced Alchemy provides sync and async…
permissive · top 15,000 on PyPI
sqlalchemy-easy-softdeleteAdds soft-deletion support to SQLAlchemy models…
permissive · top 15,000 on PyPI