{ "info": { "author": "Elmer de Looff", "author_email": "elmer.delooff@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Database" ], "description": "sqlalchemy-json\n###############\n\nSQLAlchemy-JSON provides mutation-tracked JSON types to SQLAlchemy_:\n\n* ``MutableJson`` is a straightforward implementation for keeping track of top-level changes to JSON objects;\n* ``NestedMutableJson`` is an extension of this which tracks changes even when these happen in nested objects or arrays (Python ``dicts`` and ``lists``).\n\n\nExamples\n========\n\nBasic change tracking\n---------------------\n\nThis is essentially the SQLAlchemy `mutable JSON recipe`_. We define a simple author model which list the author's name and a property ``handles`` for various social media handles used:\n\n.. code-block:: python\n\n class Author(Base):\n name = Column(Text)\n handles = Column(MutableJson)\n\nThe example below loads one of the existing authors and retrieves the mapping of social media handles. The error in the twitter handle is then corrected and committed. The change is detected by SQLAlchemy and the appropriate ``UPDATE`` statement is generated.\n\n.. code-block:: python\n\n >>> author = session.query(Author).first()\n >>> author.handles\n {'twitter': '@JohnDoe', 'facebook': 'JohnDoe'}\n >>> author.handles['twitter'] = '@JDoe'\n >>> session.commit()\n >>> author.handles\n {'twitter': '@JDoe', 'facebook': 'JohnDoe'}\n\n\nNested change tracking\n----------------------\n\nThe example below defines a simple model for articles. One of the properties on this model is a mutable JSON structure called ``references`` which includes a count of links that the article contains, grouped by domain:\n\n.. code-block:: python\n\n class Article(Base):\n author = Column(ForeignKey('author.name'))\n content = Column(Text)\n references = Column(NestedMutableJson)\n\nWith this in place, an existing article is loaded and its current references inspected. Following that, the count for one of these is increased by ten, and the session is committed:\n\n.. code-block:: python\n\n >>> article = session.query(Article).first()\n >>> article.references\n {'github.com': {'edelooff/sqlalchemy-json': 4, 'zzzeek/sqlalchemy': 7}}\n >>> article.references['github.com']['edelooff/sqlalchemy-json'] += 10\n >>> session.commit()\n >>> article.references\n {'github.com': {'edelooff/sqlalchemy-json': 14, 'zzzeek/sqlalchemy': 7}}\n\nHad the articles model used ``MutableJson`` like in the previous example this code would have failed. This is because the top level dictionary is never altered directly. The *nested* mutable ensures the change happening at the lower level *bubbles up* to the outermost container.\n\n\nDependencies\n============\n\n* ``SQLAlchemy-utils`` for its existing and database-engine specific choice of either native or simulated JSON type;\n* ``six`` to support both Python 2 and 3.\n\n\nChangelog\n=========\n\n0.2.2\n-----\n\n* Fixes a bug where assigning ``None`` to the column resulted in an error (https://github.com/edelooff/sqlalchemy-json/issues/10)\n\n\n0.2.1\n-----\n\n* Fixes a typo in the README found after uploading 0.2.0 to PyPI.\n\n\n0.2.0 (unreleased)\n------------------\n\n* Now uses ``JSONType`` provided by SQLAlchemy-utils_ to handle backend storage;\n* **Backwards incompatible**: Changed class name ``JsonObject`` to ``MutableJson`` and ``NestedJsonObject`` to ``NestedMutableJson``\n* Outermost container for ``NestedMutableJson`` can now be an ``array`` (Python ``list``)\n\n\n0.1.0 (unreleased)\n------------------\n\nInitial version. This initially carried a 1.0.0 version number but has never been released on PyPI.\n\n\n.. _mutable json recipe: http://docs.sqlalchemy.org/en/latest/core/custom_types.html#marshal-json-strings\n.. _sqlalchemy: https://www.sqlalchemy.org/\n.. _sqlalchemy-utils: https://sqlalchemy-utils.readthedocs.io/\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/edelooff/sqlalchemy-json", "keywords": "sqlalchemy json mutable", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "sqlalchemy-json", "package_url": "https://pypi.org/project/sqlalchemy-json/", "platform": "", "project_url": "https://pypi.org/project/sqlalchemy-json/", "project_urls": { "Homepage": "https://github.com/edelooff/sqlalchemy-json" }, "release_url": "https://pypi.org/project/sqlalchemy-json/0.2.3/", "requires_dist": null, "requires_python": "", "summary": "JSON type with nested change tracking for SQLAlchemy", "version": "0.2.3" }, "last_serial": 4580051, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "2f9ad4eb0ab7eb9871fb58b5f63f8729", "sha256": "fb44e5c22df404886c6baa02334b7410519987a1f16b7919ff661d5fee4d65b3" }, "downloads": -1, "filename": "sqlalchemy_json-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2f9ad4eb0ab7eb9871fb58b5f63f8729", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7592, "upload_time": "2017-09-11T21:54:32", "url": "https://files.pythonhosted.org/packages/bf/db/fd49ab75897b5c4420d9066d59cc7cf19d54189bbc3da796bcf6009bfa6f/sqlalchemy_json-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a6a164b38c14e892918291b4dc5be594", "sha256": "8a6e193cdbf7b486aa1388d3b7e93afd6f443db494414669ff7635d5918a526f" }, "downloads": -1, "filename": "sqlalchemy-json-0.2.1.tar.gz", "has_sig": false, "md5_digest": "a6a164b38c14e892918291b4dc5be594", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4905, "upload_time": "2017-09-11T21:54:35", "url": "https://files.pythonhosted.org/packages/71/6a/23f48b15de5782db96a7c7d1c0c28c2d14decd7ae65ff93b81a24a67ad4e/sqlalchemy-json-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "267c6b9ef0f1e0143f5b40f385d837bf", "sha256": "460024505539a7429ed3a5925a46780f7ced1aa2c65d737f7bde01994cdf3d9f" }, "downloads": -1, "filename": "sqlalchemy-json-0.2.2.tar.gz", "has_sig": false, "md5_digest": "267c6b9ef0f1e0143f5b40f385d837bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4959, "upload_time": "2018-10-10T13:13:55", "url": "https://files.pythonhosted.org/packages/c7/f8/b30cc697e8e046965b15d8e10e96853ec7d9c35639b60870f51da710dc12/sqlalchemy-json-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "bc7a59e2505ac4e9985467e862b4b6e2", "sha256": "d17952e771eecd9023c0f683d2a6aaa27ce1a6dbf57b0fe2bf4d5aef4c5dad1c" }, "downloads": -1, "filename": "sqlalchemy-json-0.2.3.tar.gz", "has_sig": false, "md5_digest": "bc7a59e2505ac4e9985467e862b4b6e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4959, "upload_time": "2018-12-10T10:22:56", "url": "https://files.pythonhosted.org/packages/d4/b8/0f3a7ee9c88cc45239c10a17a01503131846f0202bc5283d04ccd9e97c07/sqlalchemy-json-0.2.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bc7a59e2505ac4e9985467e862b4b6e2", "sha256": "d17952e771eecd9023c0f683d2a6aaa27ce1a6dbf57b0fe2bf4d5aef4c5dad1c" }, "downloads": -1, "filename": "sqlalchemy-json-0.2.3.tar.gz", "has_sig": false, "md5_digest": "bc7a59e2505ac4e9985467e862b4b6e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4959, "upload_time": "2018-12-10T10:22:56", "url": "https://files.pythonhosted.org/packages/d4/b8/0f3a7ee9c88cc45239c10a17a01503131846f0202bc5283d04ccd9e97c07/sqlalchemy-json-0.2.3.tar.gz" } ] }