SQLAlchemy-JSONField


NameSQLAlchemy-JSONField JSON
Version 1.0.2 PyPI version JSON
download
home_page
SummarySQLALchemy JSONField implementation for storing dicts at SQL
upload_time2023-11-22 09:31:22
maintainer
docs_urlNone
author
requires_python>=3.7.0
licenseApache-2.0
keywords sql sqlalchemy json jsonfield development
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            SQLAlchemy-JSONField
====================

.. image:: https://github.com/penguinolog/sqlalchemy_jsonfield/workflows/Python%20package/badge.svg
    :target: https://github.com/penguinolog/sqlalchemy_jsonfield/actions
.. image:: https://img.shields.io/pypi/v/sqlalchemy_jsonfield.svg
    :target: https://pypi.python.org/pypi/sqlalchemy_jsonfield
.. image:: https://img.shields.io/pypi/pyversions/sqlalchemy_jsonfield.svg
    :target: https://pypi.python.org/pypi/sqlalchemy_jsonfield
.. image:: https://img.shields.io/pypi/status/sqlalchemy_jsonfield.svg
    :target: https://pypi.python.org/pypi/sqlalchemy_jsonfield
.. image:: https://img.shields.io/github/license/penguinolog/sqlalchemy_jsonfield.svg
    :target: https://raw.githubusercontent.com/penguinolog/sqlalchemy_jsonfield/master/LICENSE
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/ambv/black

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.

.. note:: SQLite 3.9 supports JSON natively and SQLAlchemy can handle this.

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):

.. code-block:: python

  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:

.. code-block:: python

  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:

1. `GitHub actions: <https://github.com/penguinolog/sqlalchemy_jsonfield/actions>`_ is used for checking: PEP8, pylint, bandit, installation possibility and unit tests.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "SQLAlchemy-JSONField",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.0",
    "maintainer_email": "",
    "keywords": "sql,sqlalchemy,json,jsonfield,development",
    "author": "",
    "author_email": "Alexey Stepanov <penguinolog@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d0/77/88de5c9ac1a44db1abb493d9d0995681b200ad625d80a4a289c7be438d80/SQLAlchemy-JSONField-1.0.2.tar.gz",
    "platform": null,
    "description": "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 <-> JSON <-> VARCHAR example, but...\nIn real scenarios we have tests on sqlite, production on MySQL/MariaDB/Percona/PostgreSQL\nand some of them (modern Oracle MySQL & PostgreSQL) support JSON,\nsome of them (SQLite, Percona & 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: <https://github.com/penguinolog/sqlalchemy_jsonfield/actions>`_ is used for checking: PEP8, pylint, bandit, installation possibility and unit tests.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "SQLALchemy JSONField implementation for storing dicts at SQL",
    "version": "1.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/penguinolog/sqlalchemy_jsonfield/issues",
        "Repository": "https://github.com/penguinolog/sqlalchemy_jsonfield"
    },
    "split_keywords": [
        "sql",
        "sqlalchemy",
        "json",
        "jsonfield",
        "development"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fd67d75d119e70863e0519c8eec5fc66714d34ad1ee9e5e73bf4fc8e3d259fac",
                "md5": "8b3879845aac435e0a1bd244809a421f",
                "sha256": "b2945fa1e60b07d5764a7c73b18da427948b35dd4c07c0e94939001dc2dacf77"
            },
            "downloads": -1,
            "filename": "SQLAlchemy_JSONField-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8b3879845aac435e0a1bd244809a421f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.0",
            "size": 10217,
            "upload_time": "2023-11-22T09:31:20",
            "upload_time_iso_8601": "2023-11-22T09:31:20.830519Z",
            "url": "https://files.pythonhosted.org/packages/fd/67/d75d119e70863e0519c8eec5fc66714d34ad1ee9e5e73bf4fc8e3d259fac/SQLAlchemy_JSONField-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d07788de5c9ac1a44db1abb493d9d0995681b200ad625d80a4a289c7be438d80",
                "md5": "f923c939e0dd7f54b57dc02ef6f1c2ca",
                "sha256": "dab3abc9d75a1640e7f3d4875564a4199f665d27863da8d5a089e4eaca5e67f2"
            },
            "downloads": -1,
            "filename": "SQLAlchemy-JSONField-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "f923c939e0dd7f54b57dc02ef6f1c2ca",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.0",
            "size": 15879,
            "upload_time": "2023-11-22T09:31:22",
            "upload_time_iso_8601": "2023-11-22T09:31:22.468701Z",
            "url": "https://files.pythonhosted.org/packages/d0/77/88de5c9ac1a44db1abb493d9d0995681b200ad625d80a4a289c7be438d80/SQLAlchemy-JSONField-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-22 09:31:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "penguinolog",
    "github_project": "sqlalchemy_jsonfield",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "sqlalchemy-jsonfield"
}
        
Elapsed time: 0.16921s