BatchGetItem

When given a BatchGetItem, the connection will return a BatchGetItemResponse:

>>> connection(BatchGetItem().table(table).keys({"h": 0}, {"h": 1}))
<LowVoltage.actions.batch_get_item.BatchGetItemResponse ...>

Responses are accessed like this:

>>> connection(
...   BatchGetItem().table(table).keys({"h": 0})
... ).responses[table]
[{u'h': 0, u'gr': 10, u'gh': 0}]

Note that responses are in an undefined order.

See also the iterate_batch_get_item() compound. And Actions vs. compounds in the user guide.

class BatchGetItemResponse

The BatchGetItem response

consumed_capacity

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

Type:None or list of ConsumedCapacity
responses

The items you just got.

Type:None or dict of string (table name) to list of dict
unprocessed_keys

Keys that were not processed during this request. If not None, you should give this back to previous_unprocessed_keys() in a subsequent BatchGetItem.

The iterate_batch_get_item() compound does that for you.

Type:None or exactly as returned by DynamoDB
class BatchGetItem(table=None, *keys)

The BatchGetItem request

Note that this function is variadic. See Variadic functions.

Passing table (and keys) to the constructor is like calling table() on the new instance.

table(name, *keys)

Note that this function is variadic. See Variadic functions.

Set the active table. Calls to methods like keys() or consistent_read_true() will apply to this table.

>>> connection(
...   BatchGetItem()
...     .table(table)
...     .keys({"h": 1}, {"h": 2}, {"h": 3})
... )
<LowVoltage.actions.batch_get_item.BatchGetItemResponse ...>

If some keys are provided, they’ll be added to the keys to get from the table.

>>> connection(
...   BatchGetItem()
...     .table(table, {"h": 1}, {"h": 2}, {"h": 3})
... )
<LowVoltage.actions.batch_get_item.BatchGetItemResponse ...>
keys(*keys)

Note that this function is variadic. See Variadic functions.

Add keys to get from the active table.

Raise:BuilderError if called when no table is active.
>>> connection(
...   BatchGetItem()
...     .table(table)
...     .keys({"h": 1}, {"h": 2}, {"h": 3})
... )
<LowVoltage.actions.batch_get_item.BatchGetItemResponse ...>
previous_unprocessed_keys(previous_unprocessed_keys)

Set Table and Keys to retry previous unprocessed_keys.

The iterate_batch_get_item() compound does that for you.

Note that using this method is incompatible with using table() or keys() or passing a table or keys in the constructor.

consistent_read_true()

Set ConsistentRead to True. The request will use strong consistent reads.

Raise:BuilderError if called when no table is active.
>>> c = connection(
...   BatchGetItem()
...     .table(table).keys({"h": 0})
...     .consistent_read_true()
...     .return_consumed_capacity_total()
... ).consumed_capacity
>>> c[0].table_name
u'LowVoltage.Tests.Doc.1'
>>> c[0].capacity_units
1.0
consistent_read_false()

Set ConsistentRead to False. The request will use eventually consistent reads.

Raise:BuilderError if called when no table is active.
>>> c = connection(
...   BatchGetItem()
...     .table(table).keys({"h": 0})
...     .consistent_read_false()
...     .return_consumed_capacity_total()
... ).consumed_capacity
>>> c[0].table_name
u'LowVoltage.Tests.Doc.1'
>>> c[0].capacity_units
0.5
project(*names)

Note that this function is variadic. See Variadic functions.

Add name(s) to ProjectionExpression. The request will return only projected attributes.

Raise:BuilderError if called when no table is active.
>>> connection(
...   BatchGetItem()
...     .table(table)
...     .keys({"h": 0})
...     .project("h", "gr")
... ).responses[table]
[{u'h': 0, u'gr': 10}]
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.

Raise:BuilderError if called when no table is active.
>>> connection(
...   BatchGetItem()
...     .table(table)
...     .keys({"h": 0})
...     .expression_attribute_name("syn", "h")
...     .project("#syn")
... ).responses[table]
[{u'h': 0}]
return_consumed_capacity_total()

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

>>> c = connection(
...   BatchGetItem()
...     .table(table).keys({"h": 0}, {"h": 1}, {"h": 2})
...     .table(table2).keys({"h": 0, "r1": 0}, {"h": 1, "r1": 0})
...     .return_consumed_capacity_total()
... ).consumed_capacity
>>> c[0].table_name
u'LowVoltage.Tests.Doc.1'
>>> c[0].capacity_units
1.5
>>> c[1].table_name
u'LowVoltage.Tests.Doc.2'
>>> c[1].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(
...   BatchGetItem()
...     .table(table)
...     .keys({"h": 0}, {"h": 1}, {"h": 2})
...     .return_consumed_capacity_none()
... ).consumed_capacity
None