Skip to content

DynamoDBClient.get_item

rboto-dynamodb==0.4.0 · Service index · Types

Model summary (excerpt): The GetItem operation returns a set of attributes for the item with the given primary key. If there is no matching item, GetItem does not return any data and there will be no Item element in the response. GetItem provides an eventually consistent read by default. If your application requires a strongly consistent read, set ConsistentRead to true . Although a strongly consistent read might take...

Install and imports

python -m pip install "rboto[dynamodb]==0.4.0"
from rboto import DynamoDBClient
from collections.abc import Sequence
from rboto_dynamodb.types import (
    AttributeValue,
    GetItemOutput,
    ReturnConsumedCapacity,
)

Signature

async def get_item(
    *,
    table_name: str,
    key: dict[str, AttributeValue],
    attributes_to_get: Sequence[str] | None = None,
    consistent_read: bool | None = None,
    return_consumed_capacity: ReturnConsumedCapacity | None = None,
    projection_expression: str | None = None,
    expression_attribute_names: dict[str, str] | None = None,
) -> GetItemOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
table_name Yes The name of the table containing the requested item. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.
key Yes A map of attribute names to AttributeValue objects, representing the primary key of the item to retrieve. For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.
attributes_to_get No This is a legacy parameter. Use ProjectionExpression instead. For more information, see AttributesToGet in the Amazon DynamoDB Developer Guide .
consistent_read No Determines the read consistency model: If set to true , then the operation uses strongly consistent reads; otherwise, the operation uses eventually consistent reads.
return_consumed_capacity No
projection_expression No A string that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes are returned. If any of the requested attributes are not found, they do not appear in the result. For more information, see...
expression_attribute_names No One or more substitution tokens for attribute names in an expression. The following are some use cases for using ExpressionAttributeNames : To access an attribute whose name conflicts with a DynamoDB reserved word. To create a placeholder for repeating occurrences of an attribute name in an expression. To prevent special characters in an attribute name from being misinterpreted in an...

Output

GetItemOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
item dict[str, AttributeValueOutput] | None Always present AttributeValueOutput
consumed_capacity ConsumedCapacityOutput | None Always present ConsumedCapacityOutput

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

AttributeValue, GetItemOutput, ReturnConsumedCapacity

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

Import from rboto_dynamodb.exceptions:

InternalServerError, InvalidEndpointError, ProvisionedThroughputExceededError, RequestLimitExceededError, ResourceNotFoundError, ThrottlingError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Example

Complete, type-checked service example. Replace its placeholders and configure credentials before running it.

import asyncio

from rboto import DynamoDBClient
from rboto_dynamodb.types import AttributeValue


async def main() -> None:
    client = DynamoDBClient(region="us-east-1")
    key: dict[str, AttributeValue] = {"pk": {"s": "USER#123"}}
    response = await client.get_item(table_name="users", key=key)
    print(response.item)


if __name__ == "__main__":
    asyncio.run(main())

Service guide · Pinned model