Skip to main content

sqlalchemy-mutables

A minimal package for nested mutable datatypes in SQLAlchemy. Main feature is a JSON field that is RFC-7159 compliant.

Developed for SQLAlchemy v1.3.24. Your mileage may very with other versions.

Installation

$ pip install sqlalchemy-mutables

Usage

from sqlalchemy_mutables import NestedMutableListColumn

class MyTable(Base):
    mutable_list = Column(NestedMutableListColumn)
from sqlalchemy_mutables import NestedMutableDictColumn

class MyTable(Base):
    mutable_dict = Column(NestedMutableDictColumn)

JSON

To be compliant with RFC-7159, 'primitives' need to be supported as top level values. These are values of type str|int|float|bool or None. Unfortunately, these types break SQLAlchemy Mutable functionality (specifically bool as this cannot be subclassed). To allow for these while maintaining mutable functionality for list and dict, a wrapper class has to be used via a hybrid_property.

from sqlalchemy_mutables import NestedMutableJSONColumn, NestedMutableJSONProperty

class MyTable(Base):
    _mutable_json = Column("mutable_json", NestedMutableJSONColumn)
    mutable_json = NestedMutableJSONProperty("_mutable_json")

It is possible to pass a custom functionality to the getter and/or setter:

def json_getter(value):
    if isinstance(value, (int, float)):
        value = value * 2
    return value

def json_setter(value):
    if isinstance(value, (int, float)):
        value = value / 2
    return value

class MyTable(Base):
    ...
    mutable_json = NestedMutableJSONProperty(
        "_mutable_json",
        fget=json_getter,
        fset=json_setter,
    )

Passed functions are executed in the existing getter and setter in the form of value = fc(value).

Metadata

Release files for sqlalchemy-mutables 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlalchemy-mutables 0.3.1
File Size Uploaded Provenance Actions
sqlalchemy_mutables-0.3.1.tar.gz 8.0 kB Without provenance Details for sqlalchemy_mutables-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlalchemy-mutables 0.3.1
File Interpreter ABI Platform Actions
sqlalchemy_mutables-0.3.1-py3-none-any.whl Python 3 none any Details for sqlalchemy_mutables-0.3.1-py3-none-any.whl

Total release size: 13.4 kB

Release files / sqlalchemy_mutables-0.3.1.tar.gz

Download URL sqlalchemy_mutables-0.3.1.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e8e9fa1e551d9c06fc69d9d0d79dc540ee69af1a9da0aa1d4d9e74c6a9a49ebb
BLAKE2b-256 checksum
How to use checksums
813b5fd23c789dea706179b02612c398501e6e65c31c55782d3bf0f4cd633cea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / sqlalchemy_mutables-0.3.1-py3-none-any.whl

Download URL sqlalchemy_mutables-0.3.1-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3d0a6adb3df85d1863e858abf0d720a42bfdc3f3b67a5944e866534544d5c8e
BLAKE2b-256 checksum
How to use checksums
093d3c03b626762102c9e1b8e333c6860a7701376c746104d603150c89e48865
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for sqlalchemy-mutables 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page