execute_statement
async
¶
execute_statement(
resource_arn: Arn,
secret_arn: Arn,
sql: SqlStatement,
*,
config_overrides: Optional[AsyncRDSDataClientConfig] = None,
database: Optional[DbName] = None,
schema: Optional[DbName] = None,
parameters: Optional[SqlParametersList] = None,
transaction_id: Optional[Id] = None,
include_result_metadata: Optional[Boolean] = None,
continue_after_timeout: Optional[Boolean] = None,
result_set_options: Optional[ResultSetOptions] = None,
format_records_as: Optional[RecordsFormatType] = None,
) -> ExecuteStatementResponse
Runs a SQL statement against a database.
If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.
If the binary response data from the database is more than 1 MB, the call is terminated.
Parameters:
-
resource_arn(Arn) –The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
-
secret_arn(Arn) –The ARN of the secret that enables access to the DB cluster. Enter the database user name and password for the credentials in the secret.
For information about creating the secret, see Create a database secret.
When you use the CLI on Linux to reference a secret created in the RDS console, the ARN might include special characters like
rds!cluster. If you enclose the ARN in double quotes, the!character might trigger a shell expansion error, such as-bash: !cluster: event not found. To avoid this, escape the exclamation mark (\!) in the ARN or enclose the entire ARN in single quotes (') instead of double quotes.Alternatively, disable shell history expansion by running
set +Hbefore you execute the command. -
sql(SqlStatement) –The SQL statement to run.
-
database(Optional[DbName], default:None) –The name of the database.
-
schema(Optional[DbName], default:None) –The name of the database schema.
Currently, the
schemaparameter isn't supported. -
parameters(Optional[SqlParametersList], default:None) –The parameters for the SQL statement.
Array parameters are not supported.
-
transaction_id(Optional[Id], default:None) –The identifier of a transaction that was started by using the
BeginTransactionoperation. Specify the transaction ID of the transaction that you want to include the SQL statement in.If the SQL statement is not part of a transaction, don't set this parameter.
-
include_result_metadata(Optional[Boolean], default:None) –A value that indicates whether to include metadata in the results.
-
continue_after_timeout(Optional[Boolean], default:None) –A value that indicates whether to continue running the statement after the call times out. By default, the statement stops running when the call times out.
For DDL statements, we recommend continuing to run the statement after the call times out. When a DDL statement terminates before it is finished running, it can result in errors and possibly corrupted data structures.
-
result_set_options(Optional[ResultSetOptions], default:None) –Options that control how the result set is returned.
-
format_records_as(Optional[RecordsFormatType], default:None) –A value that indicates whether to format the result set as a single JSON string. This parameter only applies to
SELECTstatements and is ignored for other types of statements. Allowed values areNONEandJSON. The default value isNONE. The result is returned in theformattedRecordsfield.For usage information about the JSON format for result sets, see Using the Data API in the Amazon Aurora User Guide.
Raises:
-
AccessDeniedException–You don't have sufficient access to perform this action.
-
BadRequestException–There is an error in the call or in a SQL statement. This exception is deprecated.
-
DatabaseErrorException–There was an error in processing the SQL statement.
-
DatabaseNotFoundException–The DB cluster doesn't have a DB instance.
-
DatabaseResumingException–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.
-
DatabaseUnavailableException–The writer instance in the DB cluster isn't available.
-
ForbiddenException–There are insufficient privileges to make the call.
-
HttpEndpointNotEnabledException–The HTTP endpoint for using RDS Data API isn't enabled for the DB cluster.
-
InternalServerErrorException–An internal error occurred.
-
InvalidResourceStateException–The resource is in an invalid state.
-
InvalidSecretException–The Secrets Manager secret used with the request isn't valid.
-
SecretsErrorException–There was a problem with the Secrets Manager secret used with the request, caused by one of the following conditions:
-
RDS Data API timed out retrieving the secret.
-
The secret provided wasn't found.
-
The secret couldn't be decrypted.
-
-
ServiceUnavailableError–The service specified by the
resourceArnparameter isn't available. -
StatementTimeoutException–The execution of the SQL statement timed out.
-
TransactionNotFoundException–The transaction ID wasn't found.
-
UnsupportedResultException–There was a problem with the result because of one of the following conditions:
-
It contained an unsupported data type.
-
It contained a multidimensional array.
-
The size was too large.
-
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_rds_data/_services/async_rds_data.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | |