Complete the code to specify the DynamoDB table name in the BatchWriteItem request.
batch_write_params = {
'RequestItems': {
'[1]': []
}
}The key inside 'RequestItems' must be the exact table name where you want to write items.
Complete the code to add a PutRequest with an item containing 'id' and 'name' attributes.
batch_write_params = {
'RequestItems': {
'MyTable': [
{'[1]': {'Item': {'id': {'S': '123'}, 'name': {'S': 'Alice'}}}}
]
}
}In BatchWriteItem, to add or replace an item, you use 'PutRequest'.
Fix the error in the BatchWriteItem call by completing the missing parameter name.
response = dynamodb.[1](RequestItems=batch_write_params['RequestItems'])
The correct method to write multiple items in batch is 'batch_write_item'.
Fill both blanks to add a DeleteRequest for an item with primary key 'id' equal to '456'.
batch_write_params = {
'RequestItems': {
'MyTable': [
{'[1]': {'Key': {'id': {'S': '[2]'}}}}
]
}
}To delete an item, use 'DeleteRequest' and specify the key with the correct id value.
Fill all three blanks to create a BatchWriteItem request with one PutRequest and one DeleteRequest.
batch_write_params = {
'RequestItems': {
'MyTable': [
{'[1]': {'Item': {'id': {'S': '789'}, 'name': {'S': 'Bob'}}}},
{'[2]': {'Key': {'id': {'S': '[3]'}}}}
]
}
}The first request is a PutRequest to add an item. The second is a DeleteRequest to remove the item with id '202'.