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
-
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. 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 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.