{ "info": { "author": "Adam Johnson", "author_email": "me@adamj.eu", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "==============\nmariadb-dyncol\n==============\n\n.. image:: https://img.shields.io/pypi/v/mariadb-dyncol.svg\n :target: https://pypi.python.org/pypi/mariadb-dyncol\n\n.. image:: https://img.shields.io/travis/adamchainz/mariadb-dyncol/master.svg\n :target: https://travis-ci.org/adamchainz/mariadb-dyncol\n\nPack/unpack Python ``dict``\\s into/out of MariaDB's **Dynamic Columns** format.\n\nA quick example:\n\n.. code-block:: python\n\n >>> mariadb_dyncol.pack({\"key\": \"value\"})\n b'\\x04\\x01\\x00\\x03\\x00\\x00\\x00\\x03\\x00key!value'\n >>> mariadb_dyncol.unpack(mariadb_dyncol.pack({\"key\": \"value\"}))\n {'key': 'value'}\n\nInstallation\n============\n\nUse **pip**:\n\n.. code-block:: sh\n\n pip install mariadb-dyncol\n\nTested on Python 3.6. Python 3.4+ supported.\n\nFeatures\n========\n\n* Sensible type mapping from Python to SQL\n* Tested against examples from MariaDB, including property/fuzz testing with\n `hypothesis `_ (which is\n amazing and found many bugs)\n\nWhy?\n====\n\nThe normal way for adding data into dynamic columns fields is with the\n``COLUMN_CREATE`` function, and its relatives. This allows you to do things\nlike:\n\n.. code-block:: sql\n\n INSERT INTO mytable (attrs) VALUES (COLUMN_CREATE('key', 'value'))\n\nUnfortunately the Django ORM is restricted and cannot use database functions\nlike this in every instance, at least not until Django 1.9. It was this\nlimitation I hit whilst implementing a dynamic columns field for my project\n`django-mysql `_ that spurred the\ncreation of this library.\n\nBy pre-packing the dynamic columns, the above query can just insert the blob\nof data directly:\n\n.. code-block:: sql\n\n INSERT INTO mytable (attrs) VALUES (X'0401000300000003006B65792176616C7565')\n\nAsides from being more easily implemented with the Django ORM, this approach\nof packing/unpacking dynamic columns in Python also has some advantages:\n\n* All data types are properly preserved in Python. The only way MariaDB\n provides of pulling back all values for a dynamic columns field is to call\n ``COLUMN_JSON``, but JSON only supports strings and integers. Also\n ``COLUMN_JSON`` has a depth limit of 10, but the format has no actual limit.\n* The CPU overhead of packing/unpacking the dynamic columns is moved from you\n database server to your (presumably more scalable) clients.\n\nAPI\n===\n\nAll functions and names are accessible as attributes of the ``mariadb_dyncol``\nmodule, which you can import with ``import mariadb_dyncol``.\n\n``pack(mapping)``\n-----------------\n\nPacks the given mapping (a ``dict``) into the MariaDB Dynamic Columns\nformat for named columns and returns it as a byte string (Python 3's ``bytes``,\nPython 2's ``str``). This is suitable for then inserting into a table as part\nof a normal query.\n\nThe ``dict``\\'s keys must all be unicode strings, and the values must all be\none of the supported data types:\n\n* ``int`` between ``-(2 ** 32) + 1`` and ``(2 ** 64) - 1`` (Python 2: ``long``\n is supported too)\n* ``str`` up to 4GB encoded in UTF-8 (Python 2: ``unicode``)\n* ``float`` - anything except ``NaN`` or ``+/- inf``\n* ``datetime.datetime`` - full range supported\n* ``datetime.date`` - full range supported\n* ``datetime.time`` - full range supported\n* Any ``dict`` that is valid by these rules, allowing nested keys. There is no\n nesting limit except from for MariaDB's ``COLUMN_JSON`` function which\n restricts the depth to 10\n\nNote that this does not support the ``DECIMAL`` type that MariaDB does (and\nwould naturally map to Python's ``Decimal``) - it is a little more fiddly to\npack/unpack, though certainly possible, and pull requests are welcomed. If you\ntry and pack a ``Decimal``, a ``DynColNotSupported`` exception will be raised.\n\nThere are other restrictions on the UTF-8 encoded column names as documented in\nMariaDB:\n\n* The maximum length of a column name is 16383 bytes\n* The maximum length of all column names (at one level in nested hierarchies)\n is 65535 bytes\n\nAll other unsupported types will raise a ``DynColTypeError``. Out of range\nvalues will raise a ``DynColValueError``.\n\nExamples:\n\n.. code-block:: python\n\n >>> mariadb_dyncol.pack({\"a\": 1})\n b'\\x04\\x01\\x00\\x01\\x00\\x00\\x00\\x00\\x00a\\x02'\n >>> mariadb_dyncol.pack({\"a\": \"\ud83d\udca9\"})\n b'\\x04\\x01\\x00\\x01\\x00\\x00\\x00\\x03\\x00a!\\xf0\\x9f\\x92\\xa9'\n\n``unpack(bytestring)``\n----------------------\n\nUnpacks MariaDB dynamic columns data encoded byte string into a dict; the types\nyou can expect back are those listed above. This is suitable for fetching the\ndata direct from MariaDB and decoding in Python as opposed to with MariaDB's\n``COLUMN_JSON`` function, preserving the types that JSON discards.\n\nAs noted above, ``DECIMAL`` values are not supported, and unpacking this\nwill raise ``DynColNotSupported``. Also strings will only be decoded with the\nMySQL charsets ``utf8`` or ``utf8mb4``; strings with other charsets will raise\n``DynColNotSupported`` as well.\n\nUnsupported column formats, for example the old MariaDB numbered dynamic\ncolumns format, or corrupt data, will raise ``DynColValueError``.\n\nExamples:\n\n.. code-block:: python\n\n >>> mariadb_dyncol.unpack(b'\\x04\\x01\\x00\\x01\\x00\\x00\\x00\\x03\\x00a!\\xf0\\x9f\\x92\\xa9')\n {\"a\": \"\ud83d\udca9\"}\n >>> mariadb_dyncol.unpack(b'\\x04\\x01\\x00\\x01\\x00\\x00\\x00\\x00\\x00a\\x02')\n {\"a\": 1}\n\n\n\n\nHistory\n-------\n\nPending release\n---------------\n\n.. Insert new release notes below this line\n\n3.0.0 (2019-02-07)\n------------------\n\n* Drop Python 2 support, only Python 3.4+ is supported now.\n\n2.0.0 (2018-10-20)\n------------------\n\n* Use ``utf8mb4`` character set for encoding strings. This seemed to be broken\n for emoji on older versions of MariaDB (10.1 or 10.2?), so ``utf8`` was\n previously used, however this may have only been a display/``COLUMN_JSON``\n issue on such older versions. MariaDB internally now defaults to ``utf8mb44``\n for dynamic column strings. Since this changes the output of serialization\n slightly, please test before upgrading. Also you probably want to use\n ``utf8mb4`` for everything else MariaDB in your application if you aren't\n already - it is the default on MySQL 8+.\n\n1.2.1 (2017-12-05)\n------------------\n\n* Fix a packaging error which caused the tests to be installed alongside the\n package.\n* Don't pin version of ``six`` to 1.9.0\n\n1.2.0 (2016-05-24)\n------------------\n\n* Disallowed ``str`` values on Python 2 - always use ``unicode``\n* Added a benchmark script and made some optimizations that add up to a speed\n boost of about 10%.\n\n1.1.0 (2015-10-13)\n------------------\n\n* Tests now verify every operation against MariaDB's ``COLUMN_CHECK`` and\n ``COLUMN_CREATE`` functions\n* Fixed column order when >1 UTF8 byte characters are involved\n* Fix encoding ``int``\\s around size boundaries\n* Fix encoding ``time``\\s and ``datetime``\\s with microseconds=0\n* Fix encoding float ``-0.0``\n* Fix a data size boundaries off-by-one error\n* Fix decoding ``utf8mb4`` strings\n\n1.0.0 (2015-10-09)\n------------------\n\n* Support to pack and unpack the named dynamic columns format. No support for\n DECIMAL values or strings with a non utf8mb4 charset.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/adamchainz/mariadb-dyncol", "keywords": "MariaDB", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "mariadb-dyncol", "package_url": "https://pypi.org/project/mariadb-dyncol/", "platform": "", "project_url": "https://pypi.org/project/mariadb-dyncol/", "project_urls": { "Homepage": "https://github.com/adamchainz/mariadb-dyncol" }, "release_url": "https://pypi.org/project/mariadb-dyncol/3.0.0/", "requires_dist": null, "requires_python": ">=3.4", "summary": "Pack/unpack Python dicts into/out of MariaDB's Dynamic Columns format.", "version": "3.0.0" }, "last_serial": 4792756, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "3e50df23ad5f2294af6f8c209632735d", "sha256": "036c304e6ee2045f172d2cb49198a736b5a2dafc55690e2cb1988bcb9d07f4b0" }, "downloads": -1, "filename": "mariadb_dyncol-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3e50df23ad5f2294af6f8c209632735d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9162, "upload_time": "2015-10-09T13:22:05", "url": "https://files.pythonhosted.org/packages/ed/74/3934e52b4369bdde6f5062eaed48e806d42fdcb5e21929ed7d0e922e713c/mariadb_dyncol-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a017a9b8929c08cbff8397585d090a21", "sha256": "a52acda46f01e9baa47e064aa53eb3c774ee773cfee73fe9c6e02b5420b2939a" }, "downloads": -1, "filename": "mariadb-dyncol-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a017a9b8929c08cbff8397585d090a21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12190, "upload_time": "2015-10-09T13:22:15", "url": "https://files.pythonhosted.org/packages/b1/91/577a8b8e132b429bd6e52e8efac9240e5d9fa96515f914c9be4ac2726f45/mariadb-dyncol-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "63b2929fda894eed41edb69ffe01cbbe", "sha256": "28ed5a6cb4d466f745c937bc4324baae9c9df816676e9309b501c017d40ff4d8" }, "downloads": -1, "filename": "mariadb_dyncol-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "63b2929fda894eed41edb69ffe01cbbe", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9660, "upload_time": "2015-10-13T20:42:51", "url": "https://files.pythonhosted.org/packages/3f/65/923b46c9b3a5dce38e4d6fef857265149fb69e8b4cc4da9e7f444299b707/mariadb_dyncol-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "530eee27d6fc3de435c440ae2f0a1f8f", "sha256": "b4b2f9bf55a5444332f0b450372d9947c16bd68d1efe0c7410c6a224f9d64659" }, "downloads": -1, "filename": "mariadb-dyncol-1.1.0.tar.gz", "has_sig": false, "md5_digest": "530eee27d6fc3de435c440ae2f0a1f8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13589, "upload_time": "2015-10-13T20:42:57", "url": "https://files.pythonhosted.org/packages/21/89/2ee22b841b0a17e60eb37fc71d69e6412da17b294f7389bdb18d157a4a2f/mariadb-dyncol-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "43673620105f7c687670d8626f84f2f6", "sha256": "b2bcf3bdf8fc06b8334c4530a4a7c13282622bac9eaf3c41b6492cbad70043d5" }, "downloads": -1, "filename": "mariadb_dyncol-1.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "43673620105f7c687670d8626f84f2f6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16739, "upload_time": "2016-05-24T14:11:19", "url": "https://files.pythonhosted.org/packages/c2/50/e672ef81859e02af658cef96a5d3be96ca216ea0047e30a8b4e4dc26c2dd/mariadb_dyncol-1.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c70fd30f3e02fb089a85bae33a541420", "sha256": "70a19d3b71cf2443bbffa3307493e36b75935989042d774c4bac382a3dbf430d" }, "downloads": -1, "filename": "mariadb-dyncol-1.2.0.tar.gz", "has_sig": false, "md5_digest": "c70fd30f3e02fb089a85bae33a541420", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14843, "upload_time": "2016-05-24T14:11:36", "url": "https://files.pythonhosted.org/packages/93/7a/2b89d575aaa2e82cad4638b29d4b8e7ccf2ecb6497902274d0ec78b95e7a/mariadb-dyncol-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "24ef8c04239d3df47a42837234002f1f", "sha256": "25f0985264db818b78f4fbaa67ca38b9b8dfee81338cf8b396bb9fbadcaba134" }, "downloads": -1, "filename": "mariadb_dyncol-1.2.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "24ef8c04239d3df47a42837234002f1f", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12507, "upload_time": "2017-12-05T14:18:28", "url": "https://files.pythonhosted.org/packages/9a/f3/b66906d1e59b66cd9182769a3d5274dd6603d65bf023e774de46ab0ef6b2/mariadb_dyncol-1.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2f8bb9f8dd7281fa349348610aecfff2", "sha256": "7348b6c33be0328ea4288656bf60273391f9fe582e6ae56d9b639dbd887158ff" }, "downloads": -1, "filename": "mariadb-dyncol-1.2.1.tar.gz", "has_sig": true, "md5_digest": "2f8bb9f8dd7281fa349348610aecfff2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14592, "upload_time": "2017-12-05T14:18:26", "url": "https://files.pythonhosted.org/packages/23/12/60e3ce462929ac0d183d07f10038ebf3e252683518fc821623c4e9923811/mariadb-dyncol-1.2.1.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "721df687862240c27b029c7a5bbe5a1b", "sha256": "aabc61a3311ffa8e89306cce293d95ee7674fd2b8d925b2aaed5c2b2f110e00f" }, "downloads": -1, "filename": "mariadb_dyncol-2.0.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "721df687862240c27b029c7a5bbe5a1b", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9020, "upload_time": "2018-10-20T14:28:52", "url": "https://files.pythonhosted.org/packages/af/c5/9544b54564a2cd79d6d8b35adee59782e5bf44c8dd8d9f20c271b26fb162/mariadb_dyncol-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9026c84a5b7af529f953397ec8aab659", "sha256": "847317643c8c47df431433ee4d966f818d89e1f9342ec66d126dc924b6d06dce" }, "downloads": -1, "filename": "mariadb-dyncol-2.0.0.tar.gz", "has_sig": true, "md5_digest": "9026c84a5b7af529f953397ec8aab659", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16955, "upload_time": "2018-10-20T14:28:49", "url": "https://files.pythonhosted.org/packages/2f/92/9859bae9f7516055a6e23face9fe5e7f8fe1de7d48052019031ad553b09a/mariadb-dyncol-2.0.0.tar.gz" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "42c7e68fb7e9dbfbe2d5e33caf3d2c41", "sha256": "99383a649772a2e7043fa831ee1dc7f0358b4011f6a2b59a881bba128ce48d2e" }, "downloads": -1, "filename": "mariadb_dyncol-3.0.0-py3-none-any.whl", "has_sig": true, "md5_digest": "42c7e68fb7e9dbfbe2d5e33caf3d2c41", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 8851, "upload_time": "2019-02-07T19:57:25", "url": "https://files.pythonhosted.org/packages/49/8a/a4c763ffc41d3b4656a5c8811360e49010a32e6e5c4bae19f7f7a95755d0/mariadb_dyncol-3.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cb5341793f7c6e89d9f9645bb4af202e", "sha256": "b96b84886b3522583930341a2dd47fad5899d7e04b87d2aaf543982c9196733b" }, "downloads": -1, "filename": "mariadb-dyncol-3.0.0.tar.gz", "has_sig": true, "md5_digest": "cb5341793f7c6e89d9f9645bb4af202e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 14336, "upload_time": "2019-02-07T19:57:27", "url": "https://files.pythonhosted.org/packages/6d/c0/736a7642176400441294c0d146bedbf1b4e2b7f829f68e88ec93872c71ba/mariadb-dyncol-3.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "42c7e68fb7e9dbfbe2d5e33caf3d2c41", "sha256": "99383a649772a2e7043fa831ee1dc7f0358b4011f6a2b59a881bba128ce48d2e" }, "downloads": -1, "filename": "mariadb_dyncol-3.0.0-py3-none-any.whl", "has_sig": true, "md5_digest": "42c7e68fb7e9dbfbe2d5e33caf3d2c41", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 8851, "upload_time": "2019-02-07T19:57:25", "url": "https://files.pythonhosted.org/packages/49/8a/a4c763ffc41d3b4656a5c8811360e49010a32e6e5c4bae19f7f7a95755d0/mariadb_dyncol-3.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cb5341793f7c6e89d9f9645bb4af202e", "sha256": "b96b84886b3522583930341a2dd47fad5899d7e04b87d2aaf543982c9196733b" }, "downloads": -1, "filename": "mariadb-dyncol-3.0.0.tar.gz", "has_sig": true, "md5_digest": "cb5341793f7c6e89d9f9645bb4af202e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 14336, "upload_time": "2019-02-07T19:57:27", "url": "https://files.pythonhosted.org/packages/6d/c0/736a7642176400441294c0d146bedbf1b4e2b7f829f68e88ec93872c71ba/mariadb-dyncol-3.0.0.tar.gz" } ] }