batch_execute_statement
async
¶
batch_execute_statement(
sqls: SqlList,
*,
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,
execution_mode: Optional[ExecutionMode] = None,
wait_time_seconds: Optional[WaitTimeSeconds] = None,
) -> BatchExecuteStatementOutput
Runs one or more SQL statements, which can be data manipulation language (DML) or data definition language (DDL). 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:
-
sqls(SqlList) –One or more SQL statements to run. The SQL statements run serially in the order of the array. Subsequent SQL statements don't start until the previous statement in the array completes. By default, the SQL statements are run as a single transaction. If any SQL statement fails, all work is rolled back. To change this behavior, see the
ExecutionModeparameter. -
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 statements run.
-
statement_name(Optional[StatementNameString], default:None) –The name of the SQL statements. You can name the SQL statements when you create them to identify the query.
-
parameters(Optional[SqlParametersList], default:None) –The parameters for the SQL statements. The parameters are available to all SQL statements in the batch. Each statement can reference any subset of the provided parameters. Each provided parameter must be referenced by at least one SQL statement in the batch.
-
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.
-
execution_mode(Optional[ExecutionMode], default:None) –Determines how the SQL statements in the batch are run. If set to
TRANSACTION(the default), all SQL statements are run as a single transaction and they are committed or rolled back together. If set toAUTO_COMMIT, each SQL statement is committed individually, and a failure of one statement does not affect the others. -
wait_time_seconds(Optional[WaitTimeSeconds], default:None) –The number of seconds to wait for all SQL statements in the batch to complete execution before returning the response. If the SQL statements do 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.
-
BatchExecuteStatementException–An 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
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |