AWS DynamoDB snippets
How to drop a DynamoDB table with Python boto3
Please note that this snippet is part of the DynamoDB-Simpsons-episodes-full-example repository on GitHub.
Let's say you want to drop the simpsonsEpisodes
table in DynamoDB.
TABLENAME='simpsonsEpisodes'
First of all, you have to create a Client (follow these steps) and then you can use the following code to assign a value to the variables used below.
dynamodbClient.delete_table(
TableName=TABLENAME
)
{'TableDescription': {'TableName': 'simpsonsEpisodes',
'TableStatus': 'DELETING',
'ProvisionedThroughput': {'NumberOfDecreasesToday': 0,
'ReadCapacityUnits': 1,
'WriteCapacityUnits': 1},
'TableSizeBytes': 0,
'ItemCount': 0,
'TableArn': 'arn:aws:dynamodb:us-east-1:526274010548:table/simpsonsEpisodes',
'TableId': '68a43e23-8341-4de6-ba2c-d89e650166b8'},
'ResponseMetadata': {'RequestId': 'VF4KF4SKTE0TV75R61MFKQ19EBVV4KQNSO5AEMVJF66Q9ASUAAJG',
'HTTPStatusCode': 200,
'HTTPHeaders': {'server': 'Server',
'date': 'Wed, 07 Dec 2022 16:24:09 GMT',
'content-type': 'application/x-amz-json-1.0',
'content-length': '334',
'connection': 'keep-alive',
'x-amzn-requestid': 'VF4KF4SKTE0TV75R61MFKQ19EBVV4KQNSO5AEMVJF66Q9ASUAAJG',
'x-amz-crc32': '225399914'},
'RetryAttempts': 0}}