BatchWriteItem¶
When given a BatchWriteItem
, the connection will return a BatchWriteItemResponse
:
>>> connection(
... BatchWriteItem().table(table).delete({"h": 0}, {"h": 1})
... )
<LowVoltage.actions.batch_write_item.BatchWriteItemResponse ...>
See also the batch_put_item()
and batch_delete_item()
compounds. And Actions vs. compounds in the user guide.
-
class
BatchWriteItemResponse
¶ -
-
consumed_capacity
¶ The capacity consumed by the request. If you used
return_consumed_capacity_total()
orreturn_consumed_capacity_indexes()
.Type: None
or list ofConsumedCapacity
-
item_collection_metrics
¶ Metrics about the collection of the items you just updated. If a LSI was touched and you used
return_item_collection_metrics_size()
.Type: None
or dict of string (table name) to list ofItemCollectionMetrics
-
unprocessed_items
¶ Items that were not processed during this request. If not None, you should give this back to:meth:~BatchWriteItem.previous_unprocessed_items in a subsequent
BatchWriteItem
.The
batch_put_item()
andbatch_delete_item()
compounds do that for you.Type: None
or exactly as returned by DynamoDB
-
-
class
BatchWriteItem
(table=None, put=[], delete=[])¶ -
Passing
table
(andput
anddelete
) to the constructor is like callingtable()
on the new instance.-
table
(name, put=[], delete=[])¶ Set the active table. Calls to methods like
delete()
orput()
will apply to this table.>>> connection( ... BatchWriteItem().table(table) ... .put({"h": 12}, {"h": 13}) ... ) <LowVoltage.actions.batch_write_item.BatchWriteItemResponse ...>
If you pass a list of items as
put
, they’ll be added to the items to put in the table.>>> connection( ... BatchWriteItem().table(table, put=[{"h": 12}, {"h": 13}]) ... ) <LowVoltage.actions.batch_write_item.BatchWriteItemResponse ...>
If you pass a list of keys as
delete
, they’ll be added to the keys to delete from the table.>>> connection( ... BatchWriteItem().table(table, delete=[{"h": 12}, {"h": 13}]) ... ) <LowVoltage.actions.batch_write_item.BatchWriteItemResponse ...>
-
put
(*items)¶ Note that this function is variadic. See Variadic functions.
Add items to put in the active table.
Raise: BuilderError
if called when no table is active.>>> connection( ... BatchWriteItem().table(table) ... .put({"h": 12}, {"h": 13}) ... ) <LowVoltage.actions.batch_write_item.BatchWriteItemResponse ...>
-
delete
(*keys)¶ Note that this function is variadic. See Variadic functions.
Add keys to delete from the active table.
Raise: BuilderError
if called when no table is active.>>> connection( ... BatchWriteItem().table(table) ... .delete({"h": 12}, {"h": 13}) ... ) <LowVoltage.actions.batch_write_item.BatchWriteItemResponse ...>
-
previous_unprocessed_items
(previous_unprocessed_items)¶ Set Table and items to retry previous
unprocessed_items
.The
batch_put_item()
andbatch_delete_item()
compounds do that for you.Note that using this method is incompatible with using
table()
,put()
ordelete()
or passing atable
orput
ordelete
in the constructor.
-
return_consumed_capacity_total
()¶ Set ReturnConsumedCapacity to TOTAL. The response will contain the total capacity consumed by this request.
>>> c = connection( ... BatchWriteItem().table(table) ... .delete({"h": 3}) ... .return_consumed_capacity_total() ... ).consumed_capacity >>> c[0].table_name u'LowVoltage.Tests.Doc.1' >>> c[0].capacity_units 2.0
-
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( ... BatchWriteItem().table(table) ... .delete({"h": 4}) ... .return_consumed_capacity_indexes() ... ).consumed_capacity >>> c[0].capacity_units 2.0 >>> c[0].table.capacity_units 1.0 >>> c[0].global_secondary_indexes["gsi"].capacity_units 1.0
-
return_consumed_capacity_none
()¶ Set ReturnConsumedCapacity to NONE. The response will not contain the capacity consumed by this request.
>>> print connection( ... BatchWriteItem().table(table).delete({"h": 5}) ... .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( ... BatchWriteItem().table(table2) ... .put({"h": 0, "r1": 0, "r2": 0}) ... .return_item_collection_metrics_size() ... ).item_collection_metrics >>> m[table2][0].item_collection_key {u'h': 0} >>> m[table2][0].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( ... BatchWriteItem().table(table2) ... .put({"h": 1, "r1": 0, "r2": 0}) ... .return_item_collection_metrics_none() ... ).item_collection_metrics None
-