sqlalchemy-serializer
Mixin for SQLAlchemy models serialization without pain
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and solves a common problem—model serialization—with minimal dependencies and low install friction. It's well-suited for Flask/FastAPI applications and other projects where lightweight, ad-hoc model-to-dict conversion is needed. Install it if you want to avoid the boilerplate of schema libraries for straightforward serialization tasks.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low friction: pure Python wheel with four runtime dependencies (SQLAlchemy, psycopg2-binary, pytz, setuptools).
- Actively maintained with recent releases; last commit 2026-05-11 and 201 repository stars indicate steady upkeep.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) allows use in commercial and proprietary projects with minimal restrictions—include a copy of the license and attribute the original author.
last release 2026-04-18 (118 days) · last repo commit 2026-05-11 · 201 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 163,975 downloads/mo, #10,558 on PyPI
Alternatives
Verify before relying
from sqlalchemy_serializer import SerializerMixin
class MyModel(db.Model, SerializerMixin):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(256))
item = MyModel.query.first()
result = item.to_dict()- Whether psycopg2-binary is required for all use cases or only when using PostgreSQL backends.
- Performance characteristics when serializing deeply nested relationships or large model graphs.
What it is and what it does
SQLAlchemy-serializer is a mixin that adds a `.to_dict()` method to SQLAlchemy model instances, turning them into dictionaries suitable for JSON responses or data export. It handles nested relationships automatically, includes support for both traditional and modern SQLAlchemy 2.0 annotation styles, and offers fine-grained control over which fields to include or exclude via `rules`, `only`, and `exclude_values` parameters.
The package is designed for developers who need simple model-to-dict conversion without the overhead of schema libraries like marshmallow. It supports custom serialization logic per column, timezone handling via pytz, recursion depth limits to prevent infinite loops, and the ability to include non-SQLAlchemy fields or method results in the output. Runtime dependencies are SQLAlchemy, psycopg2-binary, pytz, and setuptools.
Use it for
- Convert SQLAlchemy model instances to dictionaries for JSON API responses without defining separate serialization schemas.
- Exclude sensitive fields (passwords, tokens) from serialized output using negative rules or custom serializers.
- Serialize nested relationships and foreign-key references in a single call with configurable depth limits.
- Add computed or non-database fields to serialized output by including methods or properties in the rules.
- Filter out null or empty values from the serialized dictionary to reduce payload size in API responses.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and solves a common problem—model serialization—with minimal dependencies and low install friction. It's well-suited for Flask/FastAPI applications and other projects where lightweight, ad-hoc model-to-dict conversion is needed. Install it if you want to avoid the boilerplate of schema libraries for straightforward serialization tasks.
Install
sqlalchemy-serializer on PyPI
Before you install
Low friction: pure Python wheel with four runtime dependencies (SQLAlchemy, psycopg2-binary, pytz, setuptools). Actively maintained with recent releases; last commit 2026-05-11 and 201 repository stars indicate steady upkeep.
Requires Python 3.10 or later.
License in practice
MIT license (permissive) allows use in commercial and proprietary projects with minimal restrictions—include a copy of the license and attribute the original author.
Quickstart
from sqlalchemy_serializer import SerializerMixin
class MyModel(db.Model, SerializerMixin):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(256))
item = MyModel.query.first()
result = item.to_dict()
Verify before relying
- Whether psycopg2-binary is required for all use cases or only when using PostgreSQL backends.
- Performance characteristics when serializing deeply nested relationships or large model graphs.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagesSQLAlchemypsycopg2-binarypytzsetuptools |
| Maintenance | Actively maintained 118 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 163,975 / month, #10,558 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 |
Evidence: sqlalchemy_serializer-1.6.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “sqlalchemy model to dict”
- sqlalchemy-serializerAdds a `.to_dict()` method to SQLAlchemy model instances, converting…
- SQLAlchemy-JSONFieldProvides a SQLAlchemy column type for storing dictionaries as JSON,…
- sqlalchemy-mixinsProvides Active Record-style mixins for SQLAlchemy ORM, enabling…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also marshmallow-sqlalchemy · sqlalchemy-json · sqlalchemy-easy-softdelete · sqlalchemy-mixins · drf-writable-nested · voluptuous-serialize · marshmallow-jsonapi · sqlalchemy-repr · sqlacodegen · drf-jsonschema-serializer