{ "info": { "author": "Unknown", "author_email": "husanhe@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": ".. image:: https://readthedocs.org/projects/pynamodb_mate/badge/?version=latest\n :target: https://pynamodb_mate.readthedocs.io/index.html\n :alt: Documentation Status\n\n.. image:: https://travis-ci.org/MacHu-GWU/pynamodb_mate-project.svg?branch=master\n :target: https://travis-ci.org/MacHu-GWU/pynamodb_mate-project?branch=master\n\n.. image:: https://codecov.io/gh/MacHu-GWU/pynamodb_mate-project/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/MacHu-GWU/pynamodb_mate-project\n\n.. image:: https://img.shields.io/pypi/v/pynamodb_mate.svg\n :target: https://pypi.python.org/pypi/pynamodb_mate\n\n.. image:: https://img.shields.io/pypi/l/pynamodb_mate.svg\n :target: https://pypi.python.org/pypi/pynamodb_mate\n\n.. image:: https://img.shields.io/pypi/pyversions/pynamodb_mate.svg\n :target: https://pypi.python.org/pypi/pynamodb_mate\n\n.. image:: https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social\n :target: https://github.com/MacHu-GWU/pynamodb_mate-project\n\n------\n\n\n.. image:: https://img.shields.io/badge/Link-Document-blue.svg\n :target: https://pynamodb_mate.readthedocs.io/index.html\n\n.. image:: https://img.shields.io/badge/Link-API-blue.svg\n :target: https://pynamodb_mate.readthedocs.io/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Source_Code-blue.svg\n :target: https://pynamodb_mate.readthedocs.io/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Install-blue.svg\n :target: `install`_\n\n.. image:: https://img.shields.io/badge/Link-GitHub-blue.svg\n :target: https://github.com/MacHu-GWU/pynamodb_mate-project\n\n.. image:: https://img.shields.io/badge/Link-Submit_Issue-blue.svg\n :target: https://github.com/MacHu-GWU/pynamodb_mate-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Request_Feature-blue.svg\n :target: https://github.com/MacHu-GWU/pynamodb_mate-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Download-blue.svg\n :target: https://pypi.org/pypi/pynamodb_mate#files\n\n\nWelcome to ``pynamodb_mate`` Documentation\n==============================================================================\n\n\nFeature1. Store Large Binary Object in S3, only store S3 URI in DynamoDB\n------------------------------------------------------------------------------\n\nDynamoDB is a very good choice for **Pay-as-you-go**, **high-concurrent** key value database. Somestimes, you want to store large binary object along with Dynamodb items. Especially, in web crawler app. But Dynamodb has a limitation that one item can not be larger than 250KB. How could you solve the problem?\n\nA easy solution is to store large binary object in s3, and only store the s3 uri in Dynamodb. ``pynamodb_mate`` library provides this feature on top of ``pynamodb`` project (A DynamoDB ORM layer in Python).\n\nHere's how you define your ORM layer:\n\n.. code-block:: python\n\n from pynamodb.models import Model\n from pynamodb.attributes import UnicodeAttribute\n from pynamodb_mate.s3_backed_attribute import (\n S3BackedBinaryAttribute,\n S3BackedUnicodeAttribute,\n S3BackedMixin,\n s3_key_safe_b64encode,\n )\n\n BUCKET_NAME = \"my-bucket\"\n URI_PREFIX = \"s3://{BUCKET_NAME}/\".format(BUCKET_NAME=BUCKET_NAME)\n\n class PageModel(Model, S3BackedMixin):\n class Meta:\n table_name = \"pynamodb_mate-pages\"\n region = \"us-east-1\"\n\n url = UnicodeAttribute(hash_key=True)\n cover_image_url = UnicodeAttribute(null=True)\n\n # this field is for html content string\n html_content = S3BackedUnicodeAttribute(\n s3_uri_getter=lambda obj: URI_PREFIX + s3_key_safe_b64encode(obj.url) + \".html\",\n compress=True,\n )\n # this field is for image binary content\n cover_image_content = S3BackedBinaryAttribute(\n s3_uri_getter=lambda obj: URI_PREFIX + s3_key_safe_b64encode(obj.cover_image_url) + \".jpg\",\n compress=True,\n )\n\nHere's how you store large binary to s3:\n\n.. code-block:: python\n\n url = \"http://www.python.org\"\n url_cover_image = \"http://www.python.org/logo.jpg\"\n\n html_content = \"Hello World!\\n\" * 1000\n cover_image_content = (\"this is a dummy image!\\n\" * 1000).encode(\"utf-8\")\n\n page = PageModel(url=url, cover_image_url=url_cover_image)\n\n # create, if something wrong with s3.put_object in the middle,\n # dirty s3 object will be cleaned up\n page.atomic_save(\n s3_backed_data=[\n page.html_content.set_to(html_content),\n page.cover_image_content.set_to(cover_image_content)\n ]\n )\n\n # update, if something wrong with s3.put_object in the middle,\n # partially done new s3 object will be roll back\n html_content_new = \"Good Bye!\\n\" * 1000\n cover_image_content_new = (\"this is another dummy image!\\n\" * 1000).encode(\"utf-8\")\n\n page.atomic_update(\n s3_backed_data=[\n page.html_content.set_to(html_content_new),\n page.cover_image_content.set_to(cover_image_content_new),\n ]\n )\n\n # delete, make sure s3 object are all gone\n page.atomic_delete()\n\n\n.. _install:\n\nInstall\n------------------------------------------------------------------------------\n\n``pynamodb_mate`` is released on PyPI, so all you need is:\n\n.. code-block:: console\n\n $ pip install pynamodb_mate\n\nTo upgrade to latest version:\n\n.. code-block:: console\n\n $ pip install --upgrade pynamodb_mate\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://pypi.python.org/pypi/pynamodb_mate/0.0.1#downloads", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/MacHu-GWU/", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pynamodb-mate", "package_url": "https://pypi.org/project/pynamodb-mate/", "platform": "Windows", "project_url": "https://pypi.org/project/pynamodb-mate/", "project_urls": { "Download": "https://pypi.python.org/pypi/pynamodb_mate/0.0.1#downloads", "Homepage": "https://github.com/MacHu-GWU/" }, "release_url": "https://pypi.org/project/pynamodb-mate/0.0.1/", "requires_dist": [ "pynamodb", "sphinx (==1.8.1) ; extra == 'docs'", "sphinx-rtd-theme ; extra == 'docs'", "sphinx-jinja ; extra == 'docs'", "sphinx-copybutton ; extra == 'docs'", "docfly (>=0.0.17) ; extra == 'docs'", "rstobj (>=0.0.5) ; extra == 'docs'", "pygments ; extra == 'docs'", "pytest (==3.2.3) ; extra == 'tests'", "pytest-cov (==2.5.1) ; extra == 'tests'" ], "requires_python": "", "summary": "Provide Addtional Features for pynamodb", "version": "0.0.1" }, "last_serial": 5412335, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "47b425870cb247a6186a27a4b1d87e90", "sha256": "1f1f91613574b1f4eee1e11a542467060e562f058e4f234aa16d05faa4117108" }, "downloads": -1, "filename": "pynamodb_mate-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "47b425870cb247a6186a27a4b1d87e90", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11632, "upload_time": "2019-06-17T21:36:16", "url": "https://files.pythonhosted.org/packages/54/4d/2f4e351134c341ec57dddc64bf4affb7870cc7e0c65c4adfbaec35f69a40/pynamodb_mate-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8f6ca5a7fc768f2bcc97dc291e2d61cf", "sha256": "1775b2dbb95919b633bd8ba119c6c019b4d8fb65e87f8c5b5c3d700853533c0d" }, "downloads": -1, "filename": "pynamodb_mate-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8f6ca5a7fc768f2bcc97dc291e2d61cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13444, "upload_time": "2019-06-17T21:36:19", "url": "https://files.pythonhosted.org/packages/70/af/b74a0a76da887d9f21db6df8a75761a19a820c20a12cca0fb5206e2621dc/pynamodb_mate-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "47b425870cb247a6186a27a4b1d87e90", "sha256": "1f1f91613574b1f4eee1e11a542467060e562f058e4f234aa16d05faa4117108" }, "downloads": -1, "filename": "pynamodb_mate-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "47b425870cb247a6186a27a4b1d87e90", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11632, "upload_time": "2019-06-17T21:36:16", "url": "https://files.pythonhosted.org/packages/54/4d/2f4e351134c341ec57dddc64bf4affb7870cc7e0c65c4adfbaec35f69a40/pynamodb_mate-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8f6ca5a7fc768f2bcc97dc291e2d61cf", "sha256": "1775b2dbb95919b633bd8ba119c6c019b4d8fb65e87f8c5b5c3d700853533c0d" }, "downloads": -1, "filename": "pynamodb_mate-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8f6ca5a7fc768f2bcc97dc291e2d61cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13444, "upload_time": "2019-06-17T21:36:19", "url": "https://files.pythonhosted.org/packages/70/af/b74a0a76da887d9f21db6df8a75761a19a820c20a12cca0fb5206e2621dc/pynamodb_mate-0.0.1.tar.gz" } ] }