Skip to main content

AWS DynamoDB utility for parsing DynamoDB responses

Project description

Grid Smarter Cities

Build Status License: MIT PyPI

AWS DynamoDB Parser

AWS DynamoDB utility for parsing DynamoDB responses


pip install aws-dynamodb-parser

Package Contents


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.


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(
        "id": {"S": "a77b5fc0-75cb-408c-bebf-863873506cce"},
        "timestamp": {"S": "2020-10-01 13:13:47.388492"}

item = response.get("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)
# {'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(
    KeyConditionExpression="#id = :id",
        "#id": "id"
        ":id": {"S": "a77b5fc0-75cb-408c-bebf-863873506cce"}

items = response.get("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)
# [{'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'}]


Users can get the docstring help by running:

from aws_dynamodb_parser import parse


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 aws-dynamodb-parser, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size aws_dynamodb_parser-0.1.2-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size aws-dynamodb-parser-0.1.2.tar.gz (3.7 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