airflow.providers.snowflake.hooks.snowflake

Module Contents

class airflow.providers.snowflake.hooks.snowflake.SnowflakeHook(*args, **kwargs)[source]

Bases: airflow.hooks.dbapi.DbApiHook

A client to interact with Snowflake.

This hook requires the snowflake_conn_id connection. The snowflake host, login, and, password field must be setup in the connection. Other inputs can be defined in the connection or hook instantiation. If used with the S3ToSnowflakeOperator add 'aws_access_key_id' and 'aws_secret_access_key' to extra field in the connection.

Parameters
  • snowflake_conn_id (str) -- Reference to Snowflake connection id

  • account (Optional[str]) -- snowflake account name

  • authenticator (Optional[str]) -- authenticator for Snowflake. 'snowflake' (default) to use the internal Snowflake authenticator 'externalbrowser' to authenticate using your web browser and Okta, ADFS or any other SAML 2.0-compliant identify provider (IdP) that has been defined for your account 'https://<your_okta_account_name>.okta.com' to authenticate through native Okta.

  • warehouse (Optional[str]) -- name of snowflake warehouse

  • database (Optional[str]) -- name of snowflake database

  • region (Optional[str]) -- name of snowflake region

  • role (Optional[str]) -- name of snowflake role

  • schema (Optional[str]) -- name of snowflake schema

  • session_parameters (Optional[dict]) -- You can set session-level parameters at the time you connect to Snowflake

Note

get_sqlalchemy_engine() depends on snowflake-sqlalchemy

See also

For more information on how to use this Snowflake connection, take a look at the guide: SnowflakeOperator

conn_name_attr = snowflake_conn_id[source]
default_conn_name = snowflake_default[source]
conn_type = snowflake[source]
hook_name = Snowflake[source]
supports_autocommit = True[source]
static get_connection_form_widgets()[source]

Returns connection widgets to add to connection form

static get_ui_field_behaviour()[source]

Returns custom field behaviour

_get_conn_params(self)[source]

One method to fetch connection params as a dict used in get_uri() and get_connection()

get_uri(self)[source]

Override DbApiHook get_uri method for get_sqlalchemy_engine()

get_conn(self)[source]

Returns a snowflake.connection object

_get_aws_credentials(self)[source]

Returns aws_access_key_id, aws_secret_access_key from extra

intended to be used by external import and export statements

set_autocommit(self, conn, autocommit: Any)[source]
get_autocommit(self, conn)[source]
run(self, sql: Union[str, list], autocommit: bool = False, parameters: Optional[dict] = None)[source]

Runs a command or a list of commands. Pass a list of sql statements to the sql parameter to get them to execute sequentially

Parameters
  • sql (str or list) -- the sql string to be executed with possibly multiple statements, or a list of sql statements to execute

  • autocommit (bool) -- What to set the connection's autocommit setting to before executing the query.

  • parameters (dict or iterable) -- The parameters to render the SQL query with.

Was this entry helpful?