Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

DynamoDB ORM using dataclasses

Project description


API interface for Amazon Web Services DynamoDB built on top of PEP 557 Data Classes.

The goal is to have something that is fully a dataclass class, but gets some helpers bolted on allowing for retrieving/storing the objects in DynamoDB.

Basic Usage

>>> import botocore
>>> from moto import mock_dynamodb2
>>> from dynamoclasses import dynamoclass
>>> mock_dynamodb2().start()
>>> session = botocore.session.get_session()
>>> client = session.create_client("dynamodb")
>>> client.create_table(
...     TableName="inventory",
...     KeySchema=[
...         {"AttributeName": "item_id", "KeyType": "HASH"},
...     ],
...     AttributeDefinitions=[
...         {"AttributeName": "item_id", "AttributeType": "S"},
...     ],
...     ProvisionedThroughput={"ReadCapacityUnits": 1, "WriteCapacityUnits": 1},
... )
{'TableDescription': ...}
>>> @dynamoclass(table_name="inventory", partition_key_name="item_id")
... class InventoryItem:
...     item_id: str
>>> item = InventoryItem("hammers")
{'Attributes': ...}
>>> found_item = InventoryItem.get(partition_key="hammers", sort_key=None)
>>> print(found_item.item_id)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dynamoclasses, version 1.0.0a1
Filename, size File type Python version Upload date Hashes
Filename, size dynamoclasses-1.0.0a1-py2.py3-none-any.whl (4.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size dynamoclasses-1.0.0a1.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page