Parses dynamodb responses into a list dictionaries with attribute names as keys
Project description
Dynamodb Pretty Parser
THIS PACKAGE IS NOW PART OF the appsync-tools package Use it instead
https://github.com/QuiNovas/appsync-tools
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
Built Distribution
File details
Details for the file dynamodb-prettyparser-1.0.4.tar.gz
.
File metadata
- Download URL: dynamodb-prettyparser-1.0.4.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f34b13940e4798704ffa3b5199d40d265a3a63521ca1b4a09bd41a83d6477c2e |
|
MD5 | bf0754fd294c513ea00c0e6ec90cc741 |
|
BLAKE2b-256 | 66e95c32f6436d4781f917b14a853ae4cb05f316ec91e350d53f4eb3d02b9e77 |
File details
Details for the file dynamodb_prettyparser-1.0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: dynamodb_prettyparser-1.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 7.6 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/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df8a68a165c7aee8dc05768aca91d618e1121a6a6215d3e2a9dedd0881b9174 |
|
MD5 | e74dfa108ed3d4a65d5f7e65fc0084d0 |
|
BLAKE2b-256 | dea8f63c2591ab3a683c5abd59e96066cab213e566fbf507a65c9f82b817d1ab |