question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: support DynamoDB image values to dict with built-in Python types

See original GitHub issue

Use case

When using DynamoDBRecord class, the values for old_image and new_image are represented as Dict[str, AttributeValue]. This representation is sufficient when the data parsed is simple and does not contain nested maps/lists. But when the data parsed contains nested maps/lists, then it becomes hard to get to the data that AttributeValue represents. One would need to recursively parse the AttributeValue objects in the nested dicts to get to the underlying data.

Solution/User Experience

Using a deserializer similar to the TypeDeserializer provided by boto3 (link to code), one would be able to convert image to a Python dict where the values would be built-in Python types.

Alternative solutions

No response

Acknowledgment

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
shanabcommented, Oct 11, 2022

What about using boto3’s TypeDeserializer ?

That can be an option, but to my knowledge then one would not be able to do the following:

@event_source(data_class=DynamoDBStreamEvent)
def lambda_handler(event: DynamoDBStreamEvent, context):
    pass

because you’d need the raw Python dictionary for NewImage and OldImage to be able to use TypeDeserializer, and the event won’t expose that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with items and attributes - Amazon DynamoDB
The basic building blocks of Amazon DynamoDB start with tables, items, and attributes. ... An attribute value can be a scalar, a set,...
Read more >
DynamoDB — Boto3 Docs 1.26.34 documentation - AWS
With DynamoDB, you can create database tables that can store and retrieve any amount of data, and serve any level of request traffic....
Read more >
How to convert a boto3 Dynamo DB item to a regular ...
Yes It is a dict object but the types have to be made explicit. That's why I refer to it as a conversion....
Read more >
Python Add to Dictionary – Adding an Item to a Dict
Data structures help us organize and store collections of data. Python has built-in data structures like Lists, Sets, ...
Read more >
Amazon DynamoDB: What It Is and 10 Things You Should Know
Amazon DynamoDB is a managed NoSQL service with strong consistency and predictability, ... DynamoDB supports the following data types:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found