awswrangler.data_api.redshift.RedshiftDataApi

class awswrangler.data_api.redshift.RedshiftDataApi(cluster_id: str = '', database: str = '', workgroup_name: str = '', secret_arn: str = '', db_user: str = '', sleep: float = 0.25, backoff: float = 1.5, retries: int = 15, boto3_session: Session | None = None)

Provides access to a Redshift cluster via the Data API.

Note

When connecting to a standard Redshift cluster, cluster_id is used. When connecting to Redshift Serverless, workgroup_name is used. These two arguments are mutually exclusive.

Parameters:
  • cluster_id (str) – Id for the target Redshift cluster - only required if workgroup_name not provided.

  • database (str) – Target database name.

  • workgroup_name (str) – Name for the target serverless Redshift workgroup - only required if cluster_id not provided.

  • secret_arn (str) – The ARN for the secret to be used for authentication - only required if db_user not provided.

  • db_user (str) – The database user to generate temporary credentials for - only required if secret_arn not provided.

  • sleep (float) – Number of seconds to sleep between result fetch attempts - defaults to 0.25.

  • backoff (float) – Factor by which to increase the sleep between result fetch attempts - defaults to 1.5.

  • retries (int) – Maximum number of result fetch attempts - defaults to 15.

  • boto3_session (boto3.Session(), optional) – The boto3 session. If None, the default boto3 session is used.

__init__(cluster_id: str = '', database: str = '', workgroup_name: str = '', secret_arn: str = '', db_user: str = '', sleep: float = 0.25, backoff: float = 1.5, retries: int = 15, boto3_session: Session | None = None) None

Methods

__init__([cluster_id, database, ...])

batch_execute(sql[, database, ...])

Batch execute SQL statements against a Data API Service.

begin_transaction([database, schema])

Start an SQL transaction.

close()

Close underlying endpoint connections.

commit_transaction(transaction_id)

Commit an SQL transaction.

execute(sql[, database, transaction_id, ...])

Execute SQL statement against a Data API Service.

rollback_transaction(transaction_id)

Roll back an SQL transaction.