Course 2 - Introduction to Source Systems - DynamoDB - Practice Lab 2

In the screenshot below, we are attempting to perform a batch insert into a DynamoDB table. I would like to understand how PutRequest and Item are managed in this context. I know that we need to specify the attribute types to include a particular attribute in the item. However, in the case of single item insertion using put_item, we accessed the item with the code item=item['PutRequest']['Item'] in Exercise 2, command 25. I’m curious about how this is handled during a batch insert operation.

Hello @harish_adusumalli

In order to understand the inner workings of the DynamoDB.Client.batch_write_item method better, you can read the documentation. As you can see in the example provided in the documentation, the objects used in the input dictionary of this method can be of two forms: DeleteRequest and PutRequest. The method automatically looks for another key item inside the PutRequest value and inserts that item into the database.