Skip to content

begin_transaction async

begin_transaction(
    resource_arn: Arn,
    secret_arn: Arn,
    *,
    config_overrides: Optional[AsyncRDSDataClientConfig] = None,
    database: Optional[DbName] = None,
    schema: Optional[DbName] = None,
) -> BeginTransactionResponse

Starts a SQL transaction.

A transaction can run for a maximum of 24 hours. A transaction is terminated and rolled back automatically after 24 hours.

A transaction times out if no calls use its transaction ID in three minutes. If a transaction times out before it's committed, it's rolled back automatically.

For Aurora MySQL, DDL statements inside a transaction cause an implicit commit. We recommend that you run each MySQL DDL statement in a separate ExecuteStatement call with continueAfterTimeout enabled.

Parameters:

  • resource_arn (Arn) –

    The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

  • secret_arn (Arn) –

    The name or ARN of the secret that enables access to the DB cluster.

  • database (Optional[DbName], default: None ) –

    The name of the database.

  • schema (Optional[DbName], default: None ) –

    The name of the database schema.

Raises:

Source code in docs_src/capo_rds_data/_services/async_rds_data.py
async def begin_transaction(
    self,
    resource_arn: "capo_rds_data.types.arn.Arn",
    secret_arn: "capo_rds_data.types.arn.Arn",
    *,
    config_overrides: Optional[AsyncRDSDataClientConfig] = None,
    database: Optional["capo_rds_data.types.db_name.DbName"] = None,
    schema: Optional["capo_rds_data.types.db_name.DbName"] = None,
) -> "capo_rds_data.types.begin_transaction_response.BeginTransactionResponse":
    """<p>Starts a SQL transaction.</p> <note> <p>A transaction can run for a maximum of 24 hours. A transaction is terminated and rolled back automatically after 24 hours.</p> <p>A transaction times out if no calls use its transaction ID in three minutes. If a transaction times out before it's committed, it's rolled back automatically.</p> <p>For Aurora MySQL, DDL statements inside a transaction cause an implicit commit. We recommend that you run each MySQL DDL statement in a separate <code>ExecuteStatement</code> call with <code>continueAfterTimeout</code> enabled.</p> </note>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.</p>
        secret_arn: <p>The name or ARN of the secret that enables access to the DB cluster.</p>
        database: <p>The name of the database.</p>
        schema: <p>The name of the database schema.</p>

    Raises:
        capo_rds_data.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_rds_data.errors.bad_request_exception.BadRequestException: <p>There is an error in the call or in a SQL statement. This exception is deprecated.</p>
        capo_rds_data.errors.database_error_exception.DatabaseErrorException: <p>There was an error in processing the SQL statement.</p>
        capo_rds_data.errors.database_not_found_exception.DatabaseNotFoundException: <p>The DB cluster doesn't have a DB instance.</p>
        capo_rds_data.errors.database_resuming_exception.DatabaseResumingException: <p>A request was cancelled because the Aurora Serverless DB instance was paused. The Data API request automatically resumes the DB instance. Wait a few seconds and try again.</p>
        capo_rds_data.errors.database_unavailable_exception.DatabaseUnavailableException: <p>The writer instance in the DB cluster isn't available.</p>
        capo_rds_data.errors.forbidden_exception.ForbiddenException: <p>There are insufficient privileges to make the call.</p>
        capo_rds_data.errors.http_endpoint_not_enabled_exception.HttpEndpointNotEnabledException: <p>The HTTP endpoint for using RDS Data API isn't enabled for the DB cluster.</p>
        capo_rds_data.errors.internal_server_error_exception.InternalServerErrorException: <p>An internal error occurred.</p>
        capo_rds_data.errors.invalid_resource_state_exception.InvalidResourceStateException: <p>The resource is in an invalid state.</p>
        capo_rds_data.errors.invalid_secret_exception.InvalidSecretException: <p>The Secrets Manager secret used with the request isn't valid.</p>
        capo_rds_data.errors.secrets_error_exception.SecretsErrorException: <p>There was a problem with the Secrets Manager secret used with the request, caused by one of the following conditions:</p> <ul> <li> <p>RDS Data API timed out retrieving the secret.</p> </li> <li> <p>The secret provided wasn't found.</p> </li> <li> <p>The secret couldn't be decrypted.</p> </li> </ul>
        capo_rds_data.errors.service_unavailable_error.ServiceUnavailableError: <p>The service specified by the <code>resourceArn</code> parameter isn't available.</p>
        capo_rds_data.errors.statement_timeout_exception.StatementTimeoutException: <p>The execution of the SQL statement timed out.</p>
        capo_rds_data.errors.transaction_not_found_exception.TransactionNotFoundException: <p>The transaction ID wasn't found.</p>
        capo_rds_data.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_rds_data.types.begin_transaction_request.BeginTransactionRequest]",
    ) -> AsyncOperationResponse[
        "capo_rds_data.types.begin_transaction_response.BeginTransactionResponse"
    ]:
        import capo_rds_data._operations.rds_data_service.begin_transaction

        (
            output,
            http_response,
        ) = await capo_rds_data._operations.rds_data_service.begin_transaction.async_begin_transaction(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("BeginTransaction")
    )
    input_: capo_rds_data.types.begin_transaction_request.BeginTransactionRequest = {
        "resource_arn": resource_arn,
        "secret_arn": secret_arn,
    }
    if database is not None:
        input_["database"] = database
    if schema is not None:
        input_["schema"] = schema

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