asyncio wrapper of PynamoDB
Project description
InPynamoDB
This transforms PynamoDB's basic methods working asynchronously used aiobotocore.
This library may be merged into PynamoDB as a feature of it, but for the time being, you can use this library if you need to run any operation on DynamoDB asynchronously.
From introduction of PynamoDB:
A Pythonic interface for Amazon's DynamoDB that supports Python 2 and 3. (InPynamoDB supports from Python 3.6 because this uses async/await.)
DynamoDB is a great NoSQL service provided by Amazon, but the API is verbose. PynamoDB presents you with a simple, elegant API.
Requirements
- Python 3.6 and above for this library is using
async/await
keyword.
Installation
$ pip install InPynamoDB
Basic Usage
This library is not well-documented. If you know how to use asyncio with async/await syntax, you will know where to change from PynamoDB syntax since it is very intuitive to use if you know how to use PynamoDB and asyncio.
Detailed document will be available, soon. (Please bear with me)
For the time being, please refer to PynamoDB documentation.
Defining model
from inpynamodb.models import Model
from inpynamodb.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)
# you can declare model:
user = UserModel(email="hgd@testing.com", first_name="gildong", last_name="hong")
Basic Manipulation
# GET
user = await UserModel.get(hash_key="John", range_key="Doe")
# BATCH_GET
async for user in UserModel.batch_get(keys): # `keys` argument should be list.
print(user.id)
# ...
- UPDATE
await user.update(actions=[UserModel.first_name.set("new_first_name")])
Contribution
Any form of contribution is always welcome! This library uses poetry
as package manager, so you have to install poetry to install required packages.
Please leave issues in any form, I will check ASAP.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for InPynamoDB-4.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58da32b0c3b95c9bffac309bfbf12c03819585a241bc767503a95c5bbf933838 |
|
MD5 | 50f4e0f9dd3fd0b57a5d38577254101d |
|
BLAKE2b-256 | 9a97f5c1d745cb9ef5924cfe6a3029a636828090c59cdb9c0ae69de96afa0cef |