Boto 3の勉強 その6 (DynamoDB)

今日は、DynamoDBのテーブルを削除する。

Amazon DynamoDB — Boto3 Docs 1.21.27 documentation

と言っても、コードはTable.delete()を実行するだけ。 なので、本当に消えたかも確認する。

client = boto3.client("dynamodb")

table = dynamodb.Table("users")

response = client.describe_table(TableName="users")
print(response)

実行結果は下記
Requested resource not found: Table: users not foundのメッセージが確認できる。

% python sample-dynamodb.py
Traceback (most recent call last):
  File "/Users/nzw/dev/Python/boto3_Pj/sample-dynamodb.py", line 10, in <module>
    response = client.describe_table(TableName="users")
  File "/Users/nzw/dev/Python/boto3_Pj/.venv/lib/python3.9/site-packages/botocore/client.py", line 395, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/nzw/dev/Python/boto3_Pj/.venv/lib/python3.9/site-packages/botocore/client.py", line 725, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the DescribeTable operation: Requested resource not found: Table: users not found ★