airflow.providers.snowflake.hooks.snowflake
¶
Module Contents¶
Classes¶
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.
- Parameters
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>.okta.com
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
Note
get_sqlalchemy_engine()
depends onsnowflake-sqlalchemy
See also
For more information on how to use this Snowflake connection, take a look at the guide: SnowflakeOperator
- get_sqlalchemy_engine(engine_kwargs=None)[source]¶
Get an sqlalchemy_engine object.
- Parameters
engine_kwargs – Kwargs used in
create_engine()
.- Returns
the created engine.
- get_autocommit(conn)[source]¶
Get autocommit setting for the provided connection. Return True if conn.autocommit is set to True. Return False if conn.autocommit is not set or set to False or conn does not support autocommit.
- Parameters
conn – Connection to get autocommit setting from.
- Returns
connection autocommit setting.
- run(sql, autocommit=False, parameters=None, handler=None, split_statements=True, return_last=True, return_dictionaries=False)[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. The variable execution_info is returned so that it can be used in the Operators to modify the behavior depending on the result of the query (i.e fail the operator if the copy has processed 0 files)
- Parameters
sql (str | Iterable[str]) – 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 (Iterable | Mapping | None) – The parameters to render the SQL query with.
handler (Callable | None) – The result handler which is called with the result of each statement.
split_statements (bool) – Whether to split a single SQL string into statements and run separately
return_last (bool) – Whether to return result for only last statement or for all after split
return_dictionaries (bool) – 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 ... }
.
- Returns
return only result of the LAST SQL expression if handler was provided.
- Return type
Any | list[Any] | None