Skip to main content

Parses dynamodb responses into a list dictionaries with attribute names as keys

Project description

Parses Dynamodb responses into a more usable format. Results are returned as a list of dictionaries with the attribute names being the key. Results are parsed recursively. One use is to return results directly to Appsync from a Lambda function. Parses all scalar types that Dynamo supports

  • N (number scalar) - cast as integer or Decimal types

  • S (string scalar) - stays string

  • SS (string set scalar) - list of strings

  • NS (number set scalar) - list of Decimal/integer

  • L (list scalar) - list

  • BOOL (boolean scalar) - boolean

  • B (binary scalar) - string of base64

  • BS (binary set scalar) - list of base64 strings

  • NULL (null scalar) - None

  • M (map scalar) - Dictionary

Responses are returned formated as:

[
  {"attributeOneName": {"S": "value1"}, "attributeTwoName": {"S": "value2"}},
  {"attributeOneName": {"S": "value1"}, "attributeTwoName": {"S": "value2"}}
]

Becomes

[
  {"attributeOneName": "value1", "attributeTwoName": "value2"},
  {"attributeOneName": "value1", "attributeTwoName": "value2"}
]

Where each dictionary in the top level array is a separate item.

Methods

parseResults(records) -> dict Arguments: items – Response from any boto3 call to Dynamodb that returns Items in the response

Example

from dynamodbPrettyParser import parseResults
import boto3

dynamodb = boto3.client('dynamodb')
response = dynamodb.query(
  TableName='mytable',
  KeyConditionExpression='my_attribute = :foo',
  ExpressionAttributeValues={':foo': 'bar'}
)

print(parseResults(response))

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

dynamodb-prettyparser-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

dynamodb_prettyparser-1.0.0-py2.py3-none-any.whl (6.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dynamodb-prettyparser-1.0.0.tar.gz.

File metadata

  • Download URL: dynamodb-prettyparser-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for dynamodb-prettyparser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f91d3e59453ffde6a967a03d893e8ffdd8f3dbb9ea7a2ce7fcb6958691f5db26
MD5 82d3ab40aa2e9b6f85cb6ac62974b82c
BLAKE2b-256 20847a3a8d6b81d83e7ffd8b96651dc39577306a030a9c8d2964269899cafd58

See more details on using hashes here.

File details

Details for the file dynamodb_prettyparser-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: dynamodb_prettyparser-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for dynamodb_prettyparser-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a586e31a4297077e79feff0d89d1fe071237172f517deeb8447802d56e76a503
MD5 7ef01ed8dfc5f38d29fb8cf83a7e43c0
BLAKE2b-256 ea5f40544da4e77665ab1f03fab6b1fc3ed34afa1b6459209e3eecef38001a2d

See more details on using hashes here.

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