dynamo-db
  1. dynamo-db-delete-operation

DynamoDB DELETE Operation

Syntax

response = table.delete_item(
    Key={
        'partition_key': 'value',
        'sort_key': 'value'
    }
)

Example

import boto3

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('table_name')

response = table.delete_item(
    Key={
        'partition_key': 'abc123',
        'sort_key': 'def456'
    }
)

Output

The delete_item() method returns a dictionary containing information about the deleted item.

Explanation

The delete_item() method is used to delete an item from a DynamoDB table. It requires the primary key of the item to be deleted, which consists of a partition key and an optional sort key.

Use

The delete_item() method is used to remove a single item from a DynamoDB table. It can be used to delete an entire record or a specific field within a record.

Important Points

  • The delete_item() method requires the primary key of the item to be deleted.
  • If the item does not exist in the table, the delete_item() method does not return an error.

Summary

In summary, the delete_item() method can be used to remove a single item from a DynamoDB table. It requires the primary key of the item to be deleted and does not return an error if the item does not exist in the table.

Published on: