execute_statement
async
¶
execute_statement(
sql: StatementString,
*,
config_overrides: Optional[AsyncRedshiftDataClientConfig] = None,
cluster_identifier: Optional[ClusterIdentifierString] = None,
secret_arn: Optional[SecretArn] = None,
db_user: Optional[String] = None,
database: Optional[String] = None,
with_event: Optional[bool] = None,
statement_name: Optional[StatementNameString] = None,
parameters: Optional[SqlParametersList] = None,
workgroup_name: Optional[WorkgroupNameString] = None,
client_token: Optional[ClientToken] = None,
result_format: Optional[ResultFormatString] = None,
session_keep_alive_seconds: Optional[SessionAliveSeconds] = None,
session_id: Optional[UUID] = None,
wait_time_seconds: Optional[WaitTimeSeconds] = None,
) -> ExecuteStatementOutput
Runs an SQL statement, which can be data manipulation language (DML) or data definition language (DDL). This statement must be a single SQL statement. Depending on the authorization method, use one of the following combinations of request parameters:
-
Secrets Manager - when connecting to a cluster, provide the
secret-arnof a secret stored in Secrets Manager which hasusernameandpassword. The specified secret contains credentials to connect to thedatabaseyou specify. When you are connecting to a cluster, you also supply the database name, If you provide a cluster identifier (dbClusterIdentifier), it must match the cluster identifier stored in the secret. When you are connecting to a serverless workgroup, you also supply the database name. -
Temporary credentials - when connecting to your data warehouse, choose one of the following options:
-
When connecting to a serverless workgroup, specify the workgroup name and database name. The database user name is derived from the IAM identity. For example,
arn:iam::123456789012:user:foohas the database user nameIAM:foo. Also, permission to call theredshift-serverless:GetCredentialsoperation is required. -
When connecting to a cluster as an IAM identity, specify the cluster identifier and the database name. The database user name is derived from the IAM identity. For example,
arn:iam::123456789012:user:foohas the database user nameIAM:foo. Also, permission to call theredshift:GetClusterCredentialsWithIAMoperation is required. -
When connecting to a cluster as a database user, specify the cluster identifier, the database name, and the database user name. Also, permission to call the
redshift:GetClusterCredentialsoperation is required.
-
For more information about the Amazon Redshift Data API and CLI usage examples, see Using the Amazon Redshift Data API in the Amazon Redshift Management Guide.
Parameters:
-
sql(StatementString) –The SQL statement text to run.
-
cluster_identifier(Optional[ClusterIdentifierString], default:None) –The cluster identifier. This parameter is required when connecting to a cluster and authenticating using either Secrets Manager or temporary credentials.
-
secret_arn(Optional[SecretArn], default:None) –The name or ARN of the secret that enables access to the database. This parameter is required when authenticating using Secrets Manager.
-
db_user(Optional[String], default:None) –The database user name. This parameter is required when connecting to a cluster as a database user and authenticating using temporary credentials.
-
database(Optional[String], default:None) –The name of the database. This parameter is required when authenticating using either Secrets Manager or temporary credentials.
-
with_event(Optional[bool], default:None) –A value that indicates whether to send an event to the Amazon EventBridge event bus after the SQL statement runs.
-
statement_name(Optional[StatementNameString], default:None) –The name of the SQL statement. You can name the SQL statement when you create it to identify the query.
-
parameters(Optional[SqlParametersList], default:None) –The parameters for the SQL statement.
-
workgroup_name(Optional[WorkgroupNameString], default:None) –The serverless workgroup name or Amazon Resource Name (ARN). This parameter is required when connecting to a serverless workgroup and authenticating using either Secrets Manager or temporary credentials.
-
client_token(Optional[ClientToken], default:None) –A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
-
result_format(Optional[ResultFormatString], default:None) –The data format of the result of the SQL statement. If no format is specified, the default is JSON.
-
session_keep_alive_seconds(Optional[SessionAliveSeconds], default:None) –The number of seconds to keep the session alive after the query finishes. The maximum time a session can keep alive is 24 hours. After 24 hours, the session is forced closed and the query is terminated.
-
session_id(Optional[UUID], default:None) –The session identifier of the query.
-
wait_time_seconds(Optional[WaitTimeSeconds], default:None) –The number of seconds to wait for the SQL statement to complete execution before returning the response. If the SQL statement does not complete within the specified time, the response returns the current status. The maximum value is 30 seconds.
Raises:
-
ActiveSessionsExceededException–The Amazon Redshift Data API operation failed because the maximum number of active sessions exceeded.
-
ActiveStatementsExceededException–The number of active statements exceeds the limit.
-
ExecuteStatementException–The SQL statement encountered an environmental error while running.
-
InternalServerException–The Amazon Redshift Data API operation failed due to invalid input.
-
ResourceNotFoundException–The Amazon Redshift Data API operation failed due to a missing resource.
-
ValidationException–The Amazon Redshift Data API operation failed due to invalid input.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_redshift_data/_services/async_redshift_data.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | |