SQLAlchemy-JSONField
SQLALchemy JSONField implementation for storing dicts at SQL independently from JSON type support.
Why?
SqlAlchemy provides JSON field support for several database types (PostgreSQL and MySQL for now) and semi-working dict <-> JSON <-> VARCHAR example, but… In real scenarios we have tests on sqlite, production on MySQL/MariaDB/Percona/PostgreSQL and some of them (modern Oracle MySQL & PostgreSQL) support JSON, some of them (SQLite, Percona & MariaDB) requires data conversion to Text (not VARCHAR).
As addition, we have different levels of Unicode support on database and connector side, so we may be interested to switch JSON encoding between deployments.
Solution:
SQLALchemy JSONField has API with suport for automatic switch between native JSON and JSON encoded data, and encoding to JSON string can be enforced.
Pros:
Free software: Apache license
Open Source: https://github.com/penguinolog/sqlalchemy_jsonfield
Self-documented code: docstrings with types in comments
Uses native JSON by default, but allows to specify different library.
Support multiple Python versions
Usage
Direct usage with MariaDB (example extracted from functional tests):
import sqlalchemy_jsonfield
class ExampleTable(Base):
__tablename__ = table_name
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
row_name = sqlalchemy.Column(
sqlalchemy.Unicode(64),
unique=True,
)
json_record = sqlalchemy.Column(
sqlalchemy_jsonfield.JSONField(
# MariaDB does not support JSON for now
enforce_string=True,
# MariaDB connector requires additional parameters for correct UTF-8
enforce_unicode=False
),
nullable=False
)
Usage with alternate JSON library:
import sqlalchemy_jsonfield
import ujson
class ExampleTable(Base):
__tablename__ = table_name
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
row_name = sqlalchemy.Column(
sqlalchemy.Unicode(64),
unique=True,
)
json_record = sqlalchemy.Column(
sqlalchemy_jsonfield.JSONField(
enforce_string=True,
enforce_unicode=False,
json=ujson, # Use ujson instead of standard json.
),
nullable=False
)
Usage on PostgreSQL/Oracle MySQL(modern version)/SQLite(testing) environments allows to set enforce_string=False and use native JSON fields.
Testing
The main test mechanism for the package sqlalchemy_jsonfield is using tox. Available environments can be collected via tox -l
CI systems
For code checking several CI systems is used in parallel:
GitHub actions: is used for checking: PEP8, pylint, bandit, installation possibility and unit tests.
Release files for SQLAlchemy-JSONField 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sqlalchemy_jsonfield-1.0.3.tar.gz | 15.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sqlalchemy_jsonfield-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.7 kB
Release files / sqlalchemy_jsonfield-1.0.3.tar.gz
| Download URL | sqlalchemy_jsonfield-1.0.3.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
162099ff6b6f475105afff90b15da114cbd87fd18df94e7d091df9f9d0e4f69f
|
|
BLAKE2b-256 checksum How to use checksums |
bc159555c858379eaa76853722a4d63c6d9d4227c5889c0f9080d6b759c19100
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 11, 2026.
Transparency logRelease files / sqlalchemy_jsonfield-1.0.3-py3-none-any.whl
| Download URL | sqlalchemy_jsonfield-1.0.3-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a73ec0685a9c4330ca1374d4ff9c169748f9d29aacb5b3380f617fb9e597edfa
|
|
BLAKE2b-256 checksum How to use checksums |
003a5c75c8032d8b066cb6e757cd58a741084fbb3764a5cbb76c34ed9190a1e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 11, 2026.
Transparency log