DeleteItem

When given a DeleteItem, the connection will return a DeleteItemResponse:

>>> connection(DeleteItem(table, {"h": 0}))
<LowVoltage.actions.delete_item.DeleteItemResponse ...>

Note that deleting the same item twice is not an error (deleting is idempotent). To know if an item was actually deleted, use return_values_all_old():

>>> connection(
...   DeleteItem(table, {"h": 1})
...     .return_values_all_old()
... ).attributes
{u'h': 1, u'gr': 8, u'gh': 1}
>>> print connection(
...   DeleteItem(table, {"h": 1})
...     .return_values_all_old()
... ).attributes
None
class DeleteItemResponse

The DeleteItem response

attributes

The previous attributes of the item you just deleted. If you used return_values_all_old().

Type:None or dict
consumed_capacity

The capacity consumed by the request. If you used return_consumed_capacity_total() or return_consumed_capacity_indexes().

Type:None or ConsumedCapacity
item_collection_metrics

Metrics about the collection of the item you just deleted. If a LSI was touched and you used return_item_collection_metrics_size().

Type:None or ItemCollectionMetrics
class DeleteItem(table_name=None, key=None)

The DeleteItem request

Passing table_name to the constructor is like calling table_name() on the new instance. Passing key to the constructor is like calling key() on the new instance.

table_name(table_name)

Set TableName. Mandatory, can also be set in the constructor.

>>> connection(
...   DeleteItem(key={"h": 8})
...     .table_name(table)
... )
<LowVoltage.actions.delete_item.DeleteItemResponse ...>
key(key)

Set Key. Mandatory, can also be set in the constructor.

>>> connection(
...   DeleteItem(table_name=table)
...     .key({"h": 9})
... )
<LowVoltage.actions.delete_item.DeleteItemResponse ...>
condition_expression(expression)

Set the ConditionExpression, making the request conditional. It will raise a ConditionalCheckFailedException if the condition is not met.

>>> connection(
...   DeleteItem(table, {"h": 2})
...     .condition_expression("#syn=:val")
...     .expression_attribute_name("syn", "gr")
...     .expression_attribute_value("val", 6)
... )
<LowVoltage.actions.delete_item.DeleteItemResponse ...>
expression_attribute_name(synonym, name)

Add a synonym for an attribute name to ExpressionAttributeNames. Useful for attributes whose names don’t play well with ProjectionExpression, ConditionExpression or UpdateExpression because they contain a dot or brackets.

See condition_expression() for an example.

expression_attribute_value(name, value)

Add a named value to ExpressionAttributeValues.

See condition_expression() for an example.

return_consumed_capacity_indexes()

Set ReturnConsumedCapacity to INDEXES. The response will contain the capacity consumed by this request detailled on the table and the indexes.

>>> c = connection(
...   DeleteItem(table, {"h": 6})
...     .return_consumed_capacity_indexes()
... ).consumed_capacity
>>> c.capacity_units
2.0
>>> c.table.capacity_units
1.0
>>> c.global_secondary_indexes["gsi"].capacity_units
1.0
return_consumed_capacity_total()

Set ReturnConsumedCapacity to TOTAL. The response will contain the total capacity consumed by this request.

>>> connection(
...   DeleteItem(table, {"h": 5})
...     .return_consumed_capacity_total()
... ).consumed_capacity.capacity_units
2.0
return_consumed_capacity_none()

Set ReturnConsumedCapacity to NONE. The response will not contain the capacity consumed by this request.

>>> print connection(
...   DeleteItem(table, {"h": 7})
...     .return_consumed_capacity_none()
... ).consumed_capacity
None
return_item_collection_metrics_size()

Set ReturnItemCollectionMetrics to SIZE. If the table has a local secondary index, the response will contain metrics about the size of item collections that were touched.

>>> m = connection(
...   DeleteItem(table2, {"h": 0, "r1": 0})
...     .return_item_collection_metrics_size()
... ).item_collection_metrics
>>> m.item_collection_key
{u'h': 0}
>>> m.size_estimate_range_gb
[0.0, 1.0]
return_item_collection_metrics_none()

Set ReturnItemCollectionMetrics to NONE. The response will not contain any item collection metrics.

>>> print connection(
...   DeleteItem(table2, {"h": 1, "r1": 0})
...     .return_item_collection_metrics_none()
... ).item_collection_metrics
None
return_values_all_old()

Set ReturnValues to ALL_OLD. The response will contain all the attributes of the item in its previous state.

>>> connection(
...   DeleteItem(table, {"h": 3})
...     .return_values_all_old()
... ).attributes
{u'h': 3, u'gr': 4, u'gh': 9}
return_values_none()

Set ReturnValues to NONE. The response will not include the attributes of the item.

>>> print connection(
...   DeleteItem(table, {"h": 4})
...     .return_values_none()
... ).attributes
None