Skip to content

execute_statement async

execute_statement(
    statement: PartiQLStatement,
    *,
    config_overrides: Optional[AsyncDynamoDBClientConfig] = None,
    parameters: Optional[PreparedStatementParameters] = None,
    consistent_read: Optional[ConsistentRead] = None,
    next_token: Optional[PartiQLNextToken] = None,
    return_consumed_capacity: Optional[ReturnConsumedCapacity] = None,
    limit: Optional[PositiveIntegerObject] = None,
    return_values_on_condition_check_failure: Optional[
        ReturnValuesOnConditionCheckFailure
    ] = None,
) -> ExecuteStatementOutput

This operation allows you to perform reads and singleton writes on data stored in DynamoDB, using PartiQL.

For PartiQL reads (SELECT statement), if the total number of processed items exceeds the maximum dataset size limit of 1 MB, the read stops and results are returned to the user as a LastEvaluatedKey value to continue the read in a subsequent operation. If the filter criteria in WHERE clause does not match any data, the read will return an empty result set.

A single SELECT statement response can return up to the maximum number of items (if using the Limit parameter) or a maximum of 1 MB of data (and then apply any filtering to the results using WHERE clause). If LastEvaluatedKey is present in the response, you need to paginate the result set. If NextToken is present, you need to paginate the result set and include NextToken.

Parameters:

  • statement (PartiQLStatement) –

    The PartiQL statement representing the operation to run.

  • parameters (Optional[PreparedStatementParameters], default: None ) –

    The parameters for the PartiQL statement, if any.

  • consistent_read (Optional[ConsistentRead], default: None ) –

    The consistency of a read operation. If set to true, then a strongly consistent read is used; otherwise, an eventually consistent read is used.

  • next_token (Optional[PartiQLNextToken], default: None ) –

    Set this value to get remaining results, if NextToken was returned in the statement response.

  • limit (Optional[PositiveIntegerObject], default: None ) –

    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, along with a key in LastEvaluatedKey to apply in a subsequent operation so you can pick up where you left off. Also, if the processed dataset size exceeds 1 MB before DynamoDB reaches this limit, it stops the operation and returns the matching values up to the limit, and a key in LastEvaluatedKey to apply in a subsequent operation to continue the operation.

  • return_values_on_condition_check_failure (Optional[ReturnValuesOnConditionCheckFailure], default: None ) –

    An optional parameter that returns the item attributes for an ExecuteStatement operation that failed a condition check.

    There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed.

Raises:

  • ConditionalCheckFailedException –

    A condition specified in the operation failed to be evaluated.

  • DuplicateItemException –

    There was an attempt to insert an item with the same primary key as an item that already exists in the DynamoDB table.

  • InternalServerError –

    An error occurred on the server side.

  • ItemCollectionSizeLimitExceededException –

    An item collection is too large. This exception is only returned for tables that have one or more local secondary indexes.

  • ProvisionedThroughputExceededException –

    The request was denied due to request throttling. For detailed information about why the request was throttled and the ARN of the impacted resource, find the ThrottlingReason field in the returned exception. The Amazon Web Services SDKs for DynamoDB automatically retry requests that receive this exception. Your request is eventually successful, unless your retry queue is too large to finish. Reduce the frequency of requests and use exponential backoff. For more information, go to Error Retries and Exponential Backoff in the Amazon DynamoDB Developer Guide.

  • RequestLimitExceeded –

    Throughput exceeds the current throughput quota for your account. For detailed information about why the request was throttled and the ARN of the impacted resource, find the ThrottlingReason field in the returned exception. Contact Amazon Web Services Support to request a quota increase.

  • ResourceNotFoundException –

    The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be ACTIVE.

  • ThrottlingException –

    The request was denied due to request throttling. For detailed information about why the request was throttled and the ARN of the impacted resource, find the ThrottlingReason field in the returned exception.

  • TransactionConflictException –

    Operation was rejected because there is an ongoing transaction for the item.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_dynamodb/_services/async_dynamo_db.py
async def execute_statement(
    self,
    statement: "capo_dynamodb.types.parti_ql_statement.PartiQLStatement",
    *,
    config_overrides: Optional[AsyncDynamoDBClientConfig] = None,
    parameters: Optional[
        "capo_dynamodb.types.prepared_statement_parameters.PreparedStatementParameters"
    ] = None,
    consistent_read: Optional[
        "capo_dynamodb.types.consistent_read.ConsistentRead"
    ] = None,
    next_token: Optional[
        "capo_dynamodb.types.parti_ql_next_token.PartiQLNextToken"
    ] = None,
    return_consumed_capacity: Optional[
        "capo_dynamodb.types.return_consumed_capacity.ReturnConsumedCapacity"
    ] = None,
    limit: Optional[
        "capo_dynamodb.types.positive_integer_object.PositiveIntegerObject"
    ] = None,
    return_values_on_condition_check_failure: Optional[
        "capo_dynamodb.types.return_values_on_condition_check_failure.ReturnValuesOnConditionCheckFailure"
    ] = None,
) -> "capo_dynamodb.types.execute_statement_output.ExecuteStatementOutput":
    """<p>This operation allows you to perform reads and singleton writes on data stored in DynamoDB, using PartiQL.</p> <p>For PartiQL reads (<code>SELECT</code> statement), if the total number of processed items exceeds the maximum dataset size limit of 1 MB, the read stops and results are returned to the user as a <code>LastEvaluatedKey</code> value to continue the read in a subsequent operation. If the filter criteria in <code>WHERE</code> clause does not match any data, the read will return an empty result set.</p> <p>A single <code>SELECT</code> statement response can return up to the maximum number of items (if using the Limit parameter) or a maximum of 1 MB of data (and then apply any filtering to the results using <code>WHERE</code> clause). If <code>LastEvaluatedKey</code> is present in the response, you need to paginate the result set. If <code>NextToken</code> is present, you need to paginate the result set and include <code>NextToken</code>.</p>

    Args:
        statement: <p>The PartiQL statement representing the operation to run.</p>
        parameters: <p>The parameters for the PartiQL statement, if any.</p>
        consistent_read: <p>The consistency of a read operation. If set to <code>true</code>, then a strongly consistent read is used; otherwise, an eventually consistent read is used.</p>
        next_token: <p>Set this value to get remaining results, if <code>NextToken</code> was returned in the statement response.</p>
        limit: <p>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, along with a key in <code>LastEvaluatedKey</code> to apply in a subsequent operation so you can pick up where you left off. Also, if the processed dataset size exceeds 1 MB before DynamoDB reaches this limit, it stops the operation and returns the matching values up to the limit, and a key in <code>LastEvaluatedKey</code> to apply in a subsequent operation to continue the operation. </p>
        return_values_on_condition_check_failure: <p>An optional parameter that returns the item attributes for an <code>ExecuteStatement</code> operation that failed a condition check.</p> <p>There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed.</p>

    Raises:
        capo_dynamodb.errors.conditional_check_failed_exception.ConditionalCheckFailedException: <p>A condition specified in the operation failed to be evaluated.</p>
        capo_dynamodb.errors.duplicate_item_exception.DuplicateItemException: <p> There was an attempt to insert an item with the same primary key as an item that already exists in the DynamoDB table.</p>
        capo_dynamodb.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_dynamodb.errors.item_collection_size_limit_exceeded_exception.ItemCollectionSizeLimitExceededException: <p>An item collection is too large. This exception is only returned for tables that have one or more local secondary indexes.</p>
        capo_dynamodb.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The request was denied due to request throttling. For detailed information about why the request was throttled and the ARN of the impacted resource, find the <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ThrottlingReason.html">ThrottlingReason</a> field in the returned exception. The Amazon Web Services SDKs for DynamoDB automatically retry requests that receive this exception. Your request is eventually successful, unless your retry queue is too large to finish. Reduce the frequency of requests and use exponential backoff. For more information, go to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff">Error Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
        capo_dynamodb.errors.request_limit_exceeded.RequestLimitExceeded: <p>Throughput exceeds the current throughput quota for your account. For detailed information about why the request was throttled and the ARN of the impacted resource, find the <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ThrottlingReason.html">ThrottlingReason</a> field in the returned exception. Contact <a href="https://aws.amazon.com/support">Amazon Web Services Support</a> to request a quota increase.</p>
        capo_dynamodb.errors.resource_not_found_exception.ResourceNotFoundException: <p>The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be <code>ACTIVE</code>.</p>
        capo_dynamodb.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. For detailed information about why the request was throttled and the ARN of the impacted resource, find the <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ThrottlingReason.html">ThrottlingReason</a> field in the returned exception.</p>
        capo_dynamodb.errors.transaction_conflict_exception.TransactionConflictException: <p>Operation was rejected because there is an ongoing transaction for the item.</p>
        capo_dynamodb.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_dynamodb.types.execute_statement_input.ExecuteStatementInput]",
    ) -> AsyncOperationResponse[
        "capo_dynamodb.types.execute_statement_output.ExecuteStatementOutput"
    ]:
        import capo_dynamodb._operations.dynamo_db_20120810.execute_statement

        (
            output,
            http_response,
        ) = await capo_dynamodb._operations.dynamo_db_20120810.execute_statement.async_execute_statement(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ExecuteStatement")
    )
    input_: capo_dynamodb.types.execute_statement_input.ExecuteStatementInput = {
        "statement": statement
    }
    if parameters is not None:
        input_["parameters"] = parameters
    if consistent_read is not None:
        input_["consistent_read"] = consistent_read
    if next_token is not None:
        input_["next_token"] = next_token
    if return_consumed_capacity is not None:
        input_["return_consumed_capacity"] = return_consumed_capacity
    if limit is not None:
        input_["limit"] = limit
    if return_values_on_condition_check_failure is not None:
        input_["return_values_on_condition_check_failure"] = (
            return_values_on_condition_check_failure
        )

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output