| :py:mod:`airflow.providers.snowflake.hooks.snowflake` |
| ===================================================== |
| |
| .. py:module:: airflow.providers.snowflake.hooks.snowflake |
| |
| |
| Module Contents |
| --------------- |
| |
| Classes |
| ~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.providers.snowflake.hooks.snowflake.SnowflakeHook |
| |
| |
| |
| |
| .. py:class:: SnowflakeHook(*args, **kwargs) |
| |
| Bases: :py:obj:`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. |
| |
| :param snowflake_conn_id: Reference to |
| :ref:`Snowflake connection id<howto/connection:snowflake>` |
| :param account: snowflake account name |
| :param 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. |
| :param warehouse: name of snowflake warehouse |
| :param database: name of snowflake database |
| :param region: name of snowflake region |
| :param role: name of snowflake role |
| :param schema: name of snowflake schema |
| :param session_parameters: You can set session-level parameters at |
| the time you connect to Snowflake |
| :param insecure_mode: Turns off OCSP certificate checks. |
| For details, see: `How To: Turn Off OCSP Checking in Snowflake Client Drivers - Snowflake Community |
| <https://community.snowflake.com/s/article/How-to-turn-off-OCSP-checking-in-Snowflake-client-drivers>`__ |
| |
| .. note:: |
| ``get_sqlalchemy_engine()`` depends on ``snowflake-sqlalchemy`` |
| |
| .. seealso:: |
| For more information on how to use this Snowflake connection, take a look at the guide: |
| :ref:`howto/operator:SnowflakeOperator` |
| |
| .. py:attribute:: conn_name_attr |
| :annotation: = snowflake_conn_id |
| |
| |
| |
| .. py:attribute:: default_conn_name |
| :annotation: = snowflake_default |
| |
| |
| |
| .. py:attribute:: conn_type |
| :annotation: = snowflake |
| |
| |
| |
| .. py:attribute:: hook_name |
| :annotation: = Snowflake |
| |
| |
| |
| .. py:attribute:: supports_autocommit |
| :annotation: = True |
| |
| |
| |
| .. py:method:: get_connection_form_widgets() |
| :staticmethod: |
| |
| Returns connection widgets to add to connection form |
| |
| |
| .. py:method:: get_ui_field_behaviour() |
| :staticmethod: |
| |
| Returns custom field behaviour |
| |
| |
| .. py:method:: get_uri(self) |
| |
| Override DbApiHook get_uri method for get_sqlalchemy_engine() |
| |
| |
| .. py:method:: get_conn(self) |
| |
| Returns a snowflake.connection object |
| |
| |
| .. py:method:: get_sqlalchemy_engine(self, engine_kwargs=None) |
| |
| Get an sqlalchemy_engine object. |
| |
| :param engine_kwargs: Kwargs used in :func:`~sqlalchemy.create_engine`. |
| :return: the created engine. |
| |
| |
| .. py:method:: set_autocommit(self, conn, autocommit) |
| |
| Sets the autocommit flag on the connection |
| |
| |
| .. py:method:: get_autocommit(self, conn) |
| |
| 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. |
| |
| :param conn: Connection to get autocommit setting from. |
| :return: connection autocommit setting. |
| :rtype: bool |
| |
| |
| .. py:method:: run(self, sql, autocommit = False, parameters = None, handler = None) |
| |
| 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) |
| |
| :param sql: the sql string to be executed with possibly multiple statements, |
| or a list of sql statements to execute |
| :param autocommit: What to set the connection's autocommit setting to |
| before executing the query. |
| :param parameters: The parameters to render the SQL query with. |
| :param handler: The result handler which is called with the result of each statement. |
| |
| |
| .. py:method:: test_connection(self) |
| |
| Test the Snowflake connection by running a simple query. |
| |
| |
| |