skillfed

sqlalchemy-mixins

Active Record, Django-like queries, nested eager load and beauty __repr__ for SQLAlchemy

sqlalchemy-mixins v2.0.5 410.3K downloads/30d#6,865 on PyPI788
Permissive license MIT DORMANT released

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-mixins

uv

uv add sqlalchemy-mixins

poetry

poetry add sqlalchemy-mixins

Installing 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

Development Status :: 4 - BetaEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: Implementation :: CPythonTopic :: Database

Tags

sqlalchemy active record patterndjango-like orm queriessqlalchemy eager load mixinssqlalchemy crud helperssqlalchemy query buildersqlalchemy model mixinsactiverecord for sqlalchemy
orm-helperactiverecord-patterndjango-migration

More Database packages