GetItem¶
When given a GetItem
, the connection will return a GetItemResponse
:
>>> connection(GetItem(table, {"h": 0}))
<LowVoltage.actions.get_item.GetItemResponse ...>
The item is accessed like this:
>>> connection(GetItem(table, {"h": 0})).item
{u'h': 0, u'gr': 10, u'gh': 0}
Note that getting an unexisting item does not raise an exception:
>>> print connection(GetItem(table, {"h": -1})).item
None
-
class
GetItemResponse
¶ The GetItem response
-
consumed_capacity
¶ The capacity consumed by the request. If you used
return_consumed_capacity_total()
.Type: None
orConsumedCapacity
-
item
¶ The item you just got. None if the item is not in the table.
Type: None
or dict
-
-
class
GetItem
(table_name=None, key=None)¶ The GetItem request
Passing
table_name
to the constructor is like callingtable_name()
on the new instance. Passingkey
to the constructor is like callingkey()
on the new instance.-
table_name
(table_name)¶ Set TableName. Mandatory, can also be set in the constructor.
>>> connection( ... GetItem(key={"h": 0}) ... .table_name(table) ... ) <LowVoltage.actions.get_item.GetItemResponse ...>
-
key
(key)¶ Set Key. Mandatory, can also be set in the constructor.
>>> connection( ... GetItem(table_name=table) ... .key({"h": 0}) ... ) <LowVoltage.actions.get_item.GetItemResponse ...>
-
consistent_read_true
()¶ Set ConsistentRead to True. The request will use strong consistent reads.
>>> connection( ... GetItem(table, {"h": 0}) ... .consistent_read_true() ... .return_consumed_capacity_total() ... ).consumed_capacity.capacity_units 1.0
-
consistent_read_false
()¶ Set ConsistentRead to False. The request will use eventually consistent reads.
>>> connection( ... GetItem(table, {"h": 0}) ... .consistent_read_false() ... .return_consumed_capacity_total() ... ).consumed_capacity.capacity_units 0.5
-
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.
>>> connection( ... GetItem(table, {"h": 0}) ... .expression_attribute_name("syn", "gr") ... .project("#syn") ... ).item {u'gr': 10}
-
project
(*names)¶ Note that this function is variadic. See Variadic functions.
Add name(s) to ProjectionExpression. The request will return only projected attributes.
>>> connection( ... GetItem(table, {"h": 0}) ... .project("gr") ... ).item {u'gr': 10}
-
return_consumed_capacity_total
()¶ Set ReturnConsumedCapacity to TOTAL. The response will contain the total capacity consumed by this request.
>>> connection( ... GetItem(table, {"h": 0}) ... .return_consumed_capacity_total() ... ).consumed_capacity.capacity_units 0.5
-
return_consumed_capacity_none
()¶ Set ReturnConsumedCapacity to NONE. The response will not contain the capacity consumed by this request.
>>> print connection( ... GetItem(table, {"h": 0}) ... .return_consumed_capacity_none() ... ).consumed_capacity None
-