===========
AioPynamoDB
===========
Work in progress. Careful in production.
This library is as fork of `PynamoDB <https://github.com/pynamodb/PynamoDB>`_ to add async support.
Basic functionality is working, help to improve it is welcome.
** Known Issues **
- Python type hints needs migration. MyPy testing implementation is pending and contributions in this area are welcome.
Installation
============
From GitHub::
$ pip install git+https://github.com/brunobelloni/AioPynamoDB#egg=aiopynamodb
Basic Usage
===========
Create a model that describes your DynamoDB table.
.. code-block:: python
from aiopynamodb.models import Model
from aiopynamodb.attributes import UnicodeAttribute
class UserModel(Model):
"""
A DynamoDB User
"""
class Meta:
table_name = "dynamodb-user"
email = UnicodeAttribute(null=True)
first_name = UnicodeAttribute(range_key=True)
last_name = UnicodeAttribute(hash_key=True)
PynamoDB allows you to create the table if needed (it must exist before you can use it!):
.. code-block:: python
await UserModel.create_table(read_capacity_units=1, write_capacity_units=1)
Create a new user:
.. code-block:: python
user = UserModel("John", "Denver")
user.email = "djohn@company.org"
await user.save()
Now, search your table for all users with a last name of 'Denver' and whose
first name begins with 'J':
.. code-block:: python
async for user in UserModel.query("Denver", UserModel.first_name.startswith("J")):
print(user.first_name)
Examples of ways to query your table with filter conditions:
.. code-block:: python
async for user in UserModel.query("Denver", UserModel.email=="djohn@company.org"):
print(user.first_name)
Retrieve an existing user:
.. code-block:: python
try:
user = await UserModel.get("John", "Denver")
print(user)
except UserModel.DoesNotExist:
print("User does not exist")
Advanced Usage
==============
Want to use indexes? No problem:
.. code-block:: python
from aiopynamodb.models import Model
from aiopynamodb.indexes import GlobalSecondaryIndex, AllProjection
from aiopynamodb.attributes import NumberAttribute, UnicodeAttribute
class ViewIndex(GlobalSecondaryIndex):
class Meta:
read_capacity_units = 2
write_capacity_units = 1
projection = AllProjection()
view = NumberAttribute(default=0, hash_key=True)
class TestModel(Model):
class Meta:
table_name = "TestModel"
forum = UnicodeAttribute(hash_key=True)
thread = UnicodeAttribute(range_key=True)
view = NumberAttribute(default=0)
view_index = ViewIndex()
Now query the index for all items with 0 views:
.. code-block:: python
async for item in TestModel.view_index.query(0):
print("Item queried from index: {0}".format(item))
It's really that simple.
Raw data
{
"_id": null,
"home_page": "http://jlafon.io/pynamodb.html",
"name": "as-aiopynamodb",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "python dynamodb amazon async asyncio aiobotocore",
"author": "Jharrod LaFon",
"author_email": "jlafon@eyesopen.com",
"download_url": "https://files.pythonhosted.org/packages/4c/f7/9d15eac2202f04cff5d6dd652e30a10b70465aba21cfc5fd413723ed8c4d/as_aiopynamodb-1.0.1.tar.gz",
"platform": null,
"description": "===========\r\nAioPynamoDB\r\n===========\r\nWork in progress. Careful in production.\r\n\r\nThis library is as fork of `PynamoDB <https://github.com/pynamodb/PynamoDB>`_ to add async support.\r\n\r\nBasic functionality is working, help to improve it is welcome.\r\n\r\n\r\n** Known Issues **\r\n - Python type hints needs migration. MyPy testing implementation is pending and contributions in this area are welcome.\r\n\r\nInstallation\r\n============\r\nFrom GitHub::\r\n\r\n $ pip install git+https://github.com/brunobelloni/AioPynamoDB#egg=aiopynamodb\r\n\r\nBasic Usage\r\n===========\r\n\r\nCreate a model that describes your DynamoDB table.\r\n\r\n.. code-block:: python\r\n\r\n from aiopynamodb.models import Model\r\n from aiopynamodb.attributes import UnicodeAttribute\r\n\r\n class UserModel(Model):\r\n \"\"\"\r\n A DynamoDB User\r\n \"\"\"\r\n class Meta:\r\n table_name = \"dynamodb-user\"\r\n email = UnicodeAttribute(null=True)\r\n first_name = UnicodeAttribute(range_key=True)\r\n last_name = UnicodeAttribute(hash_key=True)\r\n\r\nPynamoDB allows you to create the table if needed (it must exist before you can use it!):\r\n\r\n.. code-block:: python\r\n\r\n await UserModel.create_table(read_capacity_units=1, write_capacity_units=1)\r\n\r\nCreate a new user:\r\n\r\n.. code-block:: python\r\n\r\n user = UserModel(\"John\", \"Denver\")\r\n user.email = \"djohn@company.org\"\r\n await user.save()\r\n\r\nNow, search your table for all users with a last name of 'Denver' and whose\r\nfirst name begins with 'J':\r\n\r\n.. code-block:: python\r\n\r\n async for user in UserModel.query(\"Denver\", UserModel.first_name.startswith(\"J\")):\r\n print(user.first_name)\r\n\r\nExamples of ways to query your table with filter conditions:\r\n\r\n.. code-block:: python\r\n\r\n async for user in UserModel.query(\"Denver\", UserModel.email==\"djohn@company.org\"):\r\n print(user.first_name)\r\n\r\nRetrieve an existing user:\r\n\r\n.. code-block:: python\r\n\r\n try:\r\n user = await UserModel.get(\"John\", \"Denver\")\r\n print(user)\r\n except UserModel.DoesNotExist:\r\n print(\"User does not exist\")\r\n\r\nAdvanced Usage\r\n==============\r\n\r\nWant to use indexes? No problem:\r\n\r\n.. code-block:: python\r\n\r\n from aiopynamodb.models import Model\r\n from aiopynamodb.indexes import GlobalSecondaryIndex, AllProjection\r\n from aiopynamodb.attributes import NumberAttribute, UnicodeAttribute\r\n\r\n class ViewIndex(GlobalSecondaryIndex):\r\n class Meta:\r\n read_capacity_units = 2\r\n write_capacity_units = 1\r\n projection = AllProjection()\r\n view = NumberAttribute(default=0, hash_key=True)\r\n\r\n class TestModel(Model):\r\n class Meta:\r\n table_name = \"TestModel\"\r\n forum = UnicodeAttribute(hash_key=True)\r\n thread = UnicodeAttribute(range_key=True)\r\n view = NumberAttribute(default=0)\r\n view_index = ViewIndex()\r\n\r\nNow query the index for all items with 0 views:\r\n\r\n.. code-block:: python\r\n\r\n async for item in TestModel.view_index.query(0):\r\n print(\"Item queried from index: {0}\".format(item))\r\n\r\nIt's really that simple.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An Async Pythonic Interface to DynamoDB",
"version": "1.0.1",
"project_urls": {
"Fork": "https://github.com/AppSolves/AioPynamoDB",
"Homepage": "http://jlafon.io/pynamodb.html",
"Original": "https://github.com/brunobelloni/AioPynamoDB"
},
"split_keywords": [
"python",
"dynamodb",
"amazon",
"async",
"asyncio",
"aiobotocore"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3769ec25f69694ec6254f2981499f41920d0194145abd6f0db2d2b004b105145",
"md5": "8a966178939f1811470c274d13048373",
"sha256": "c91e0d95bb2e0cc490be5d53bd1608cdcc78a58edcca0bb40130d8087f68fff9"
},
"downloads": -1,
"filename": "as_aiopynamodb-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8a966178939f1811470c274d13048373",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 62605,
"upload_time": "2025-09-04T00:17:27",
"upload_time_iso_8601": "2025-09-04T00:17:27.827696Z",
"url": "https://files.pythonhosted.org/packages/37/69/ec25f69694ec6254f2981499f41920d0194145abd6f0db2d2b004b105145/as_aiopynamodb-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4cf79d15eac2202f04cff5d6dd652e30a10b70465aba21cfc5fd413723ed8c4d",
"md5": "59d229c22cb70b57b586d5e5ef126776",
"sha256": "dc8cabff7782e94568e969c51c0de7995332c68c75664c06b70939ee1243105b"
},
"downloads": -1,
"filename": "as_aiopynamodb-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "59d229c22cb70b57b586d5e5ef126776",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 95989,
"upload_time": "2025-09-04T00:17:29",
"upload_time_iso_8601": "2025-09-04T00:17:29.228379Z",
"url": "https://files.pythonhosted.org/packages/4c/f7/9d15eac2202f04cff5d6dd652e30a10b70465aba21cfc5fd413723ed8c4d/as_aiopynamodb-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-04 00:17:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AppSolves",
"github_project": "AioPynamoDB",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "as-aiopynamodb"
}