AWS DynamoDB utility for parsing DynamoDB responses
Likely abandoned. No release or commit for years (last release over 5 years ago).
pip install aws-dynamodb-parserAWS DynamoDB Parser
AWS DynamoDB utility for parsing DynamoDB responses
Installation
pip install aws-dynamodb-parser
Package Contents
parse
parse is the main method exposed for parsing DynamoDB responses when using boto3.
The parse function can handle all of the data types AWS DynamoDB supports as of October 2020.
Examples
Assuming we have a table TABLE_NAME containing the following entries, with id set as the partition key and timestamp as the sort key.
All three fields included are strings.
| id | timestamp | name |
|---|---|---|
| a77b5fc0-75cb-408c-bebf-863873506cce | 2020-10-01 13:13:47.388492 | First test entry |
| a77b5fc0-75cb-408c-bebf-863873506cce | 2020-10-01 13:15:25.376589 | Second test entry |
| fa853ff0-706e-45db-b6ae-aa6a8a1f7856 | 2020-10-01 13:16:47.720778 | Third test entry |
Parsing the result from a get_item request:
import boto3
from aws_dynamodb_parser import parse
dynamodb_client = boto3.client("dynamodb")
response = dynamodb_client.get_item(
TableName="TABLE_NAME",
Key={
"id": {"S": "a77b5fc0-75cb-408c-bebf-863873506cce"},
"timestamp": {"S": "2020-10-01 13:13:47.388492"}
}
)
item = response.get("Item", {})
print(item)
# {'id': {'S': 'a77b5fc0-75cb-408c-bebf-863873506cce'}, 'timestamp': {'S': '2020-10-01 13:13:47.388492'}, 'name': {'S': 'First test entry'}}
entry = parse(item)
print(entry)
# {'id': 'a77b5fc0-75cb-408c-bebf-863873506cce', 'timestamp': '2020-10-01 13:13:47.388492', 'name': 'First test entry'}
