airflow.providers.amazon.aws.hooks.redshift

Interact with AWS Redshift clusters.

Module Contents

class airflow.providers.amazon.aws.hooks.redshift.RedshiftHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with AWS Redshift, using the boto3 library

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

See also

AwsBaseHook

Parameters

aws_conn_id (str) -- The Airflow connection used for AWS credentials.

cluster_status(self, cluster_identifier: str)[source]

Return status of a cluster

Parameters
  • cluster_identifier (str) -- unique identifier of a cluster

  • skip_final_cluster_snapshot (bool) -- determines cluster snapshot creation

  • final_cluster_snapshot_identifier (Optional[str]) -- Optional[str]

delete_cluster(self, cluster_identifier: str, skip_final_cluster_snapshot: bool = True, final_cluster_snapshot_identifier: Optional[str] = None)[source]

Delete a cluster and optionally create a snapshot

Parameters
  • cluster_identifier (str) -- unique identifier of a cluster

  • skip_final_cluster_snapshot (bool) -- determines cluster snapshot creation

  • final_cluster_snapshot_identifier (str) -- name of final cluster snapshot

describe_cluster_snapshots(self, cluster_identifier: str)[source]

Gets a list of snapshots for a cluster

Parameters

cluster_identifier (str) -- unique identifier of a cluster

restore_from_cluster_snapshot(self, cluster_identifier: str, snapshot_identifier: str)[source]

Restores a cluster from its snapshot

Parameters
  • cluster_identifier (str) -- unique identifier of a cluster

  • snapshot_identifier (str) -- unique identifier for a snapshot of a cluster

create_cluster_snapshot(self, snapshot_identifier: str, cluster_identifier: str)[source]

Creates a snapshot of a cluster

Parameters
  • snapshot_identifier (str) -- unique identifier for a snapshot of a cluster

  • cluster_identifier (str) -- unique identifier of a cluster

class airflow.providers.amazon.aws.hooks.redshift.RedshiftSQLHook[source]

Bases: airflow.hooks.dbapi.DbApiHook

Execute statements against Amazon Redshift, using redshift_connector

This hook requires the redshift_conn_id connection.

Parameters

redshift_conn_id (str) -- reference to Amazon Redshift connection id

Note

get_sqlalchemy_engine() and get_uri() depend on sqlalchemy-amazon-redshift

conn_name_attr = redshift_conn_id[source]
default_conn_name = redshift_default[source]
conn_type = redshift[source]
hook_name = Amazon Redshift[source]
supports_autocommit = True[source]
static get_ui_field_behavior()[source]

Returns custom field behavior

conn(self)[source]
get_uri(self)[source]

Overrides DbApiHook get_uri to use redshift_connector sqlalchemy dialect as driver name

get_sqlalchemy_engine(self, engine_kwargs=None)[source]

Overrides DbApiHook get_sqlalchemy_engine to pass redshift_connector specific kwargs

get_table_primary_key(self, table: str, schema: Optional[str] = 'public')[source]

Helper method that returns the table primary key :param table: Name of the target table :type table: str :param table: Name of the target schema, public by default :type table: str :return: Primary key columns list :rtype: List[str]

get_conn(self)[source]

Returns a redshift_connector.Connection object

Was this entry helpful?