:py:mod:`astronomer.providers.snowflake.hooks.snowflake_sql_api` ================================================================ .. py:module:: astronomer.providers.snowflake.hooks.snowflake_sql_api Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: astronomer.providers.snowflake.hooks.snowflake_sql_api.SnowflakeSqlApiHookAsync .. py:class:: SnowflakeSqlApiHookAsync(snowflake_conn_id, token_life_time = LIFETIME, token_renewal_delta = RENEWAL_DELTA, *args, **kwargs) Bases: :py:obj:`airflow.providers.snowflake.hooks.snowflake.SnowflakeHook` A client to interact with Snowflake using SQL API and allows submitting multiple SQL statements in a single request. In combination with aiohttp, make post request to submit SQL statements for execution, poll to check the status of the execution of a statement. Fetch query results asynchronously. This hook requires the snowflake_conn_id connection. This hooks mainly uses account, schema, database, warehouse, private_key_file or private_key_content 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` :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://.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 token_life_time: lifetime of the JWT Token in timedelta :param token_renewal_delta: Renewal time of the JWT Token in timedelta .. py:attribute:: LIFETIME .. py:attribute:: RENEWAL_DELTA .. py:method:: get_private_key() Gets the private key from snowflake connection .. py:method:: execute_query(sql, statement_count, query_tag = '', bindings = None) Using SnowflakeSQL API, run the query in snowflake by making API request :param sql: the sql string to be executed with possibly multiple statements :param statement_count: set the MULTI_STATEMENT_COUNT field to the number of SQL statements in the request :param query_tag: (Optional) Query tag that you want to associate with the SQL statement. For details, see https://docs.snowflake.com/en/sql-reference/parameters.html#label-query-tag parameter. :param bindings: (Optional) Values of bind variables in the SQL statement. When executing the statement, Snowflake replaces placeholders (? and :name) in the statement with these specified values. .. py:method:: get_headers() Based on the private key, and with connection details JWT Token is generated and header is formed .. py:method:: get_request_url_header_params(query_id) Build the request header Url with account name identifier and query id from the connection params :param query_id: statement handles query ids for the individual statements. .. py:method:: check_query_output(query_ids) Based on the query ids passed as the parameter make HTTP request to snowflake SQL API and logs the response :param query_ids: statement handles query id for the individual statements. .. py:method:: get_sql_api_query_status(query_id) :async: Based on the query id async HTTP request is made to snowflake SQL API and return response. :param query_id: statement handle id for the individual statements.