Boto 3の勉強 その4 (DynamoDB)

今日は、DynamoDBに作成したアイテムをdelete_itemで削除する。

DynamoDB — Boto3 Docs 1.21.19 documentation

table = dynamodb.Table("users")

table.delete_item(Key={"username": "janedoe", "last_name": "Doe"})

実行後にアイテムを取得してみると、以下エラーになることを確認

% python sample-dynamodb.py
Traceback (most recent call last):
  File "/Users/nzw/dev/Python/boto3_Pj/sample-dynamodb.py", line 37, in <module>
    item = response["Item"]
KeyError: 'Item'