Skip to content

DynamoDBClient.query

rboto-dynamodb==0.4.0 · Service index · Types

Model summary (excerpt): You must provide the name of the partition key attribute and a single value for that attribute. Query returns all items with that partition key value. Optionally, you can provide a sort key attribute and use a comparison operator to refine the search results. Use the KeyConditionExpression parameter to provide a specific value for the partition key. The Query operation will return all of the...

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,
    Condition,
    ConditionalOperator,
    QueryOutput,
    ReturnConsumedCapacity,
    Select,
)

Signature

async def query(
    *,
    table_name: str,
    index_name: str | None = None,
    select: Select | None = None,
    attributes_to_get: Sequence[str] | None = None,
    limit: int | None = None,
    consistent_read: bool | None = None,
    key_conditions: dict[str, Condition] | None = None,
    query_filter: dict[str, Condition] | None = None,
    conditional_operator: ConditionalOperator | None = None,
    scan_index_forward: bool | None = None,
    exclusive_start_key: dict[str, AttributeValue] | None = None,
    return_consumed_capacity: ReturnConsumedCapacity | None = None,
    projection_expression: str | None = None,
    filter_expression: str | None = None,
    key_condition_expression: str | None = None,
    expression_attribute_names: dict[str, str] | None = None,
    expression_attribute_values: dict[str, AttributeValue] | None = None,
) -> QueryOutput: ...

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 items. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.
index_name No The name of an index to query. This index can be any local secondary index or global secondary index on the table. Note that if you use the IndexName parameter, you must also provide TableName.
select No The attributes to be returned in the result. You can retrieve all item attributes, specific item attributes, the count of matching items, or in the case of an index, some or all of the attributes projected into the index. ALL_ATTRIBUTES - Returns all of the item attributes from the specified table or index. If you query a local secondary index, then for each matching item in the index,...
attributes_to_get No This is a legacy parameter. Use ProjectionExpression instead. For more information, see AttributesToGet in the Amazon DynamoDB Developer Guide .
limit No The maximum number of items to evaluate (not necessarily the number of matching items). If DynamoDB processes the number of items up to the limit while processing the results, it stops the operation and returns the matching values up to that point, and a key in LastEvaluatedKey to apply in a subsequent operation, so that you can pick up where you left off. Also, if the processed dataset size...
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. Strongly consistent reads are not supported on global secondary indexes. If you query a global secondary index with ConsistentRead set to true , you will receive a ValidationException .
key_conditions No This is a legacy parameter. Use KeyConditionExpression instead. For more information, see KeyConditions in the Amazon DynamoDB Developer Guide .
query_filter No This is a legacy parameter. Use FilterExpression instead. For more information, see QueryFilter in the Amazon DynamoDB Developer Guide .
conditional_operator No This is a legacy parameter. Use FilterExpression instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide .
scan_index_forward No Specifies the order for index traversal: If true (default), the traversal is performed in ascending order; if false , the traversal is performed in descending order. Items with the same partition key value are stored in sorted order by sort key. If the sort key data type is Number, the results are stored in numeric order. For type String, the results are stored in order of UTF-8 bytes. For...
exclusive_start_key No The primary key of the first item that this operation will evaluate. Use the value that was returned for LastEvaluatedKey in the previous operation. The data type for ExclusiveStartKey must be String, Number, or Binary. No set data types are allowed.
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 will be returned. If any of the requested attributes are not found, they will not appear in the result. For more information,...
filter_expression No A string that contains conditions that DynamoDB applies after the Query operation, but before the data is returned to you. Items that do not satisfy the FilterExpression criteria are not returned. A FilterExpression does not allow key attributes. You cannot define a filter expression based on a partition key or a sort key. A FilterExpression is applied after the items have already been read;...
key_condition_expression No The condition that specifies the key values for items to be retrieved by the Query action. The condition must perform an equality test on a single partition key value. The condition can optionally perform one of several comparison tests on a single sort key value. This allows Query to retrieve one item with a given partition key value and sort key value, or several items that have the same...
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...
expression_attribute_values No One or more values that can be substituted in an expression. Use the : (colon) character in an expression to dereference an attribute value. For example, suppose that you wanted to check whether the value of the ProductStatus attribute was one of the following: Available | Backordered | Discontinued You would first need to specify ExpressionAttributeValues as follows: {...

Output

QueryOutput.

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
items list[dict[str, AttributeValueOutput]] | None Always present AttributeValueOutput
count int Always present —
scanned_count int Always present —
last_evaluated_key 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, Condition, ConditionalOperator, QueryOutput, ReturnConsumedCapacity, Select

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

Pagination and streaming

client.paginators.query(...) accepts the same arguments and returns AsyncIterator[QueryOutput]. Direct calls return one page. Pages preserve the Output representation above.

Input cursors: exclusive_start_key. Page-size argument: limit.

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.

Service guide · Pinned model