找不到 python boto3 batch_write 响应

Can not find python boto3 batch_write response

以下代码将项目批量写入 Dynamodb:

with table.batch_writer() as batch:
  for item in chunk:   
   dynamodb_item = {
           'itemId': item['key'],
            'time': item['time'],
             'value': item['value']
                }                    
    batch.put_item( Item = dynamodb_item )     

如以下文档所述,如果批处理调用失败,returns 未处理的项目: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.batch_write_item

在boto3中,如何获取响应中未处理的项目?

如何确定是否已全部成功处理或呼叫响应是否有未处理的项目?

使用您提到的 batch_write_item,而不是 put_item

检查这个 example:

response = await client.batch_write_item(
    RequestItems=request_items
)

if len(response['UnprocessedItems']) == 0:
    print('Wrote 25 items to dynamo')
else:
    await asyncio.sleep(5)

    unprocessed_items = response['UnprocessedItems']
    # proceed with unprocessed_items