Skip to main content

asyncio wrapper of PynamoDB

Project description

InPynamoDB

Build Status Coverage Status

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

InPynamoDB-4.1.3.tar.gz (53.8 kB view hashes)

Uploaded Source

Built Distribution

InPynamoDB-4.1.3-py3-none-any.whl (60.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page