How to write a dictionary entry to a dynamodb table using DSS

dromero
Level 1
How to write a dictionary entry to a dynamodb table using DSS

I have prepared the dictionary I want to write to dynamodb. How can I 'put' that record into dynamodb. I already have a connection to it in my project.

Thanks.

0 Kudos
1 Reply
AlexT
Dataiker

Hi, 

If you have already set up the Connector for DynamoDB it would handle the writing to DynamoDB  https://www.dataiku.com/product/plugins/dynamodb/

1) You need to convert yourr dictionary to a pandas dataframe using :

df = pd.DataFrame.from_dict(actual_dict) 

2_ Then write the data frame to DynamoDB Dataset using write_with_schema()

By default, it will drop the table if it already exists in DynamoDB and recreate it with the new data.  If this is not the behavior you are looking for you can also use append for the DynamoDB output dataset.

Here are a few screenshots with a basic example a simple python recipe that essentially write the input dataset to DynamoDB:

Flow

Screenshot 2021-11-11 at 21.44.25.png

DynamoDB Dataset settings :

Screenshot 2021-11-11 at 21.44.45.png

Recipe:

Screenshot 2021-11-11 at 21.46.29.png

Written Dataset in DynamoDB

Screenshot 2021-11-11 at 21.46.13.png

Hope this helps!

 

0 Kudos