Module Contents



A client to interact with Snowflake.



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

Bases: airflow.providers.common.sql.hooks.sql.DbApiHook

A client to interact with Snowflake.

This hook requires the snowflake_conn_id connection. The snowflake account, login, and, password field must be setup in the connection. Other inputs can be defined in the connection or hook instantiation.

  • snowflake_conn_id – Reference to Snowflake connection id

  • account – snowflake account name

  • authenticator – 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> to authenticate through native Okta.

  • warehouse – name of snowflake warehouse

  • database – name of snowflake database

  • region – name of snowflake region

  • role – name of snowflake role

  • schema – name of snowflake schema

  • session_parameters – You can set session-level parameters at the time you connect to Snowflake

  • insecure_mode – Turns off OCSP certificate checks. For details, see: How To: Turn Off OCSP Checking in Snowflake Client Drivers - Snowflake Community


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]
classmethod get_connection_form_widgets()[source]

Return connection widgets to add to connection form.

classmethod get_ui_field_behaviour()[source]

Return custom field behaviour.


Override DbApiHook get_uri method for get_sqlalchemy_engine().


Return a snowflake.connection object.


Get an sqlalchemy_engine object.


engine_kwargs – Kwargs used in create_engine().


the created engine.

set_autocommit(conn, autocommit)[source]

Set the autocommit flag on the connection.


Get autocommit setting for the provided connection.


conn – Connection to get autocommit setting from.


connection autocommit setting. True if autocommit is set to True on the connection. False if it is either not set, set to False, or the connection does not support auto-commit.

run(sql: str | Iterable[str], autocommit: bool = ..., parameters: Iterable | Mapping[str, Any] | None = ..., handler: None = ..., split_statements: bool = ..., return_last: bool = ..., return_dictionaries: bool = ...) None[source]
run(sql: str | Iterable[str], autocommit: bool = ..., parameters: Iterable | Mapping[str, Any] | None = ..., handler: Callable[[Any], T] = ..., split_statements: bool = ..., return_last: bool = ..., return_dictionaries: bool = ...) tuple | list[tuple] | list[list[tuple] | tuple] | None

Run a command or list of commands.

Pass a list of SQL statements to the SQL parameter to get them to execute sequentially. The result of the queries is returned if the handler callable is set.

  • sql – The SQL string to be executed with possibly multiple statements, or a list of sql statements to execute

  • autocommit – What to set the connection’s autocommit setting to before executing the query.

  • parameters – The parameters to render the SQL query with.

  • handler – The result handler which is called with the result of each statement.

  • split_statements – Whether to split a single SQL string into statements and run separately

  • return_last – Whether to return result for only last statement or for all after split.

  • return_dictionaries – Whether to return dictionaries rather than regular DBAPI sequences as rows in the result. The dictionaries are of form { 'column1_name': value1, 'column2_name': value2 ... }.


Result of the last SQL statement if handler is set. None otherwise.


Return database specific information needed to generate and parse lineage metadata.

This includes information helpful for constructing information schema query and creating correct namespace.


connection – Airflow connection to reduce calls of get_connection method


Return database dialect used for SQL parsing.

For a list of supported dialects check:


Return default schema specific to database.


Return additional database specific lineage, e.g. query execution information.

This method is called only on completion of the task.


task_instance – this may be used to retrieve additional information that is collected during runtime of the task

Was this entry helpful?