{"id":16759680,"url":"https://github.com/penguinolog/sqlalchemy_jsonfield","last_synced_at":"2025-05-06T07:49:17.353Z","repository":{"id":57470459,"uuid":"82416966","full_name":"penguinolog/sqlalchemy_jsonfield","owner":"penguinolog","description":"SQLALchemy JSONField implementation for storing dicts at SQL independently from JSON type support","archived":false,"fork":false,"pushed_at":"2024-09-04T07:48:18.000Z","size":162,"stargazers_count":22,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-03T08:09:40.415Z","etag":null,"topics":["json","sqlalchemy"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/penguinolog.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-18T21:23:15.000Z","updated_at":"2024-10-15T09:47:24.000Z","dependencies_parsed_at":"2023-02-10T01:30:49.726Z","dependency_job_id":"bf1d91b9-82ef-42eb-ad52-382b1a4de0c5","html_url":"https://github.com/penguinolog/sqlalchemy_jsonfield","commit_stats":{"total_commits":94,"total_committers":6,"mean_commits":"15.666666666666666","dds":"0.21276595744680848","last_synced_commit":"062b8d9b705636b54d70daf9242b7bfdad99cdfd"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/penguinolog%2Fsqlalchemy_jsonfield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/penguinolog%2Fsqlalchemy_jsonfield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/penguinolog%2Fsqlalchemy_jsonfield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/penguinolog%2Fsqlalchemy_jsonfield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/penguinolog","download_url":"https://codeload.github.com/penguinolog/sqlalchemy_jsonfield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252642521,"owners_count":21781331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","sqlalchemy"],"created_at":"2024-10-13T04:08:48.152Z","updated_at":"2025-05-06T07:49:17.335Z","avatar_url":"https://github.com/penguinolog.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"SQLAlchemy-JSONField\n====================\n\n.. image:: https://github.com/penguinolog/sqlalchemy_jsonfield/workflows/Python%20package/badge.svg\n    :target: https://github.com/penguinolog/sqlalchemy_jsonfield/actions\n.. image:: https://img.shields.io/pypi/v/sqlalchemy_jsonfield.svg\n    :target: https://pypi.python.org/pypi/sqlalchemy_jsonfield\n.. image:: https://img.shields.io/pypi/pyversions/sqlalchemy_jsonfield.svg\n    :target: https://pypi.python.org/pypi/sqlalchemy_jsonfield\n.. image:: https://img.shields.io/pypi/status/sqlalchemy_jsonfield.svg\n    :target: https://pypi.python.org/pypi/sqlalchemy_jsonfield\n.. image:: https://img.shields.io/github/license/penguinolog/sqlalchemy_jsonfield.svg\n    :target: https://raw.githubusercontent.com/penguinolog/sqlalchemy_jsonfield/master/LICENSE\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/ambv/black\n\nSQLALchemy JSONField implementation for storing dicts at SQL independently from JSON type support.\n\nWhy?\n----\n\nSqlAlchemy provides JSON field support for several database types (PostgreSQL and MySQL for now)\nand semi-working dict \u003c-\u003e JSON \u003c-\u003e VARCHAR example, but...\nIn real scenarios we have tests on sqlite, production on MySQL/MariaDB/Percona/PostgreSQL\nand some of them (modern Oracle MySQL \u0026 PostgreSQL) support JSON,\nsome of them (SQLite, Percona \u0026 MariaDB) requires data conversion to Text (not VARCHAR).\n\nAs addition, we have different levels of Unicode support on database and connector side,\nso we may be interested to switch JSON encoding between deployments.\n\n.. note:: SQLite 3.9 supports JSON natively and SQLAlchemy can handle this.\n\nSolution:\n---------\n\nSQLALchemy JSONField has API with suport for automatic switch between native JSON and JSON encoded data,\nand encoding to JSON string can be enforced.\n\nPros:\n-----\n\n* Free software: Apache license\n* Open Source: https://github.com/penguinolog/sqlalchemy_jsonfield\n* Self-documented code: docstrings with types in comments\n* Uses native JSON by default, but allows to specify different library.\n* Support multiple Python versions\n\nUsage\n=====\nDirect usage with MariaDB (example extracted from functional tests):\n\n.. code-block:: python\n\n  import sqlalchemy_jsonfield\n\n  class ExampleTable(Base):\n      __tablename__ = table_name\n      id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)\n      row_name = sqlalchemy.Column(\n          sqlalchemy.Unicode(64),\n          unique=True,\n      )\n      json_record = sqlalchemy.Column(\n          sqlalchemy_jsonfield.JSONField(\n              # MariaDB does not support JSON for now\n              enforce_string=True,\n              # MariaDB connector requires additional parameters for correct UTF-8\n              enforce_unicode=False\n          ),\n          nullable=False\n      )\n\nUsage with alternate JSON library:\n\n.. code-block:: python\n\n  import sqlalchemy_jsonfield\n  import ujson\n\n  class ExampleTable(Base):\n      __tablename__ = table_name\n      id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)\n      row_name = sqlalchemy.Column(\n          sqlalchemy.Unicode(64),\n          unique=True,\n      )\n      json_record = sqlalchemy.Column(\n          sqlalchemy_jsonfield.JSONField(\n              enforce_string=True,\n              enforce_unicode=False,\n              json=ujson,  # Use ujson instead of standard json.\n          ),\n          nullable=False\n      )\n\nUsage on PostgreSQL/Oracle MySQL(modern version)/SQLite(testing) environments allows to set `enforce_string=False`\nand use native JSON fields.\n\nTesting\n=======\nThe main test mechanism for the package `sqlalchemy_jsonfield` is using `tox`.\nAvailable environments can be collected via `tox -l`\n\nCI systems\n==========\nFor code checking several CI systems is used in parallel:\n\n1. `GitHub actions: \u003chttps://github.com/penguinolog/sqlalchemy_jsonfield/actions\u003e`_ is used for checking: PEP8, pylint, bandit, installation possibility and unit tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpenguinolog%2Fsqlalchemy_jsonfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpenguinolog%2Fsqlalchemy_jsonfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpenguinolog%2Fsqlalchemy_jsonfield/lists"}