Skip to main content

Grid Smarter Cities

Build Status License: MIT PyPI

AWS 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'}

Parsing the result from a query request:

import boto3
from aws_dynamodb_parser import parse

dynamodb_client = boto3.client("dynamodb")
response = dynamodb_client.query(
    TableName="TABLE_NAME",
    KeyConditionExpression="#id = :id",
    ExpressionAttributeNames={
        "#id": "id"
    },
    ExpressionAttributeValues={
        ":id": {"S": "a77b5fc0-75cb-408c-bebf-863873506cce"}
    }
)

items = response.get("Items", [])
print(items)
# [{'id': {'S': 'a77b5fc0-75cb-408c-bebf-863873506cce'}, 'timestamp': {'S': '2020-10-01 13:13:47.388492'}, 'name': {'S': 'First test entry'}}, {'id': {'S': 'a77b5fc0-75cb-408c-bebf-863873506cce'}, 'timestamp': {'S': '2020-10-01 13:15:25.376589'}, 'name': {'S': 'Second test entry'}}]

entries = parse(items)
print(entries)
# [{'id': 'a77b5fc0-75cb-408c-bebf-863873506cce', 'timestamp': '2020-10-01 13:13:47.388492, 'name': 'First test entry'}, {'id': 'a77b5fc0-75cb-408c-bebf-863873506cce', 'timestamp': '2020-10-01 13:15:25.376589', 'name': 'Second test entry'}]

Documentation

Users can get the docstring help by running:

from aws_dynamodb_parser import parse
help(parse)

Links

Metadata

Release files for aws-dynamodb-parser 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws-dynamodb-parser 0.1.3
File Size Uploaded
aws-dynamodb-parser-0.1.3.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-dynamodb-parser 0.1.3
File Interpreter ABI Platform
aws_dynamodb_parser-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / aws-dynamodb-parser-0.1.3.tar.gz

Download URL aws-dynamodb-parser-0.1.3.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2ffad705b19aded75db42cb023a8b9944c5beb5217100a3053e3d192467f1327
BLAKE2b-256 checksum
How to use checksums
77fbc5218dca5ed917b5fb789537cd80abb587d33dae78b1cc997cde1477a809
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Release files / aws_dynamodb_parser-0.1.3-py3-none-any.whl

Download URL aws_dynamodb_parser-0.1.3-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19720dc8fcfd6a1bc49d407fccaaf9581f03be948bd370724fc4b051efa6702d
BLAKE2b-256 checksum
How to use checksums
4bd4d4348310d24c18e696ddbfaaf1f50dc2801017320c977c1f5076e14811cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page