prefect_snowflake.database
Module for querying against Snowflake databases.
Functions
snowflake_query
query: The query to execute against the database.params: The params to replace the placeholders in the query.snowflake_connector: The credentials to use to authenticate.cursor_type: The type of database cursor to use for the query.poll_frequency_seconds: Number of seconds to wait in between checks for run completion.
- The output of
response.fetchall().
snowflake_query_async
query: The query to execute against the database.params: The params to replace the placeholders in the query.snowflake_connector: The credentials to use to authenticate.cursor_type: The type of database cursor to use for the query.poll_frequency_seconds: Number of seconds to wait in between checks for run completion.
- The output of
response.fetchall().
snowflake_multiquery
queries: The list of queries to execute against the database.params: The params to replace the placeholders in the query.snowflake_connector: The credentials to use to authenticate.cursor_type: The type of database cursor to use for the query.as_transaction: If True, queries are executed in a transaction.return_transaction_control_results: Determines if the results of queries controlling the transaction (BEGIN/COMMIT) should be returned.poll_frequency_seconds: Number of seconds to wait in between checks for run completion.
- List of the outputs of
response.fetchall()for each query.
snowflake_multiquery_async
queries: The list of queries to execute against the database.params: The params to replace the placeholders in the query.snowflake_connector: The credentials to use to authenticate.cursor_type: The type of database cursor to use for the query.as_transaction: If True, queries are executed in a transaction.return_transaction_control_results: Determines if the results of queries controlling the transaction (BEGIN/COMMIT) should be returned.poll_frequency_seconds: Number of seconds to wait in between checks for run completion.
- List of the outputs of
response.fetchall()for each query.
snowflake_query_sync
query: The query to execute against the database.params: The params to replace the placeholders in the query.snowflake_connector: The credentials to use to authenticate.cursor_type: The type of database cursor to use for the query.
- The output of
response.fetchall().
Classes
SnowflakeConnector
Block used to manage connections with Snowflake.
Upon instantiating, a connection is created and maintained for the life of
the object until the close method is called.
It is recommended to use this block as a context manager, which will automatically
close the engine and its connections when the context is exited.
It is also recommended that this block is loaded and consumed within a single task
or flow because if the block is passed across separate tasks and flows,
the state of the block’s connection and cursor will be lost.
Args:
credentials: The credentials to authenticate with Snowflake.database: The name of the default database to use.warehouse: The name of the default warehouse to use.schema: The name of the default schema to use; this attribute is accessible throughSnowflakeConnector(...).schema_.fetch_size: The number of rows to fetch at a time.poll_frequency_s: The number of seconds before checking query.
close
execute
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.cursor_type: The class of the cursor to use when creating a Snowflake cursor.**execute_kwargs: Additional options to pass tocursor.execute_async.
execute_async
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.cursor_type: The class of the cursor to use when creating a Snowflake cursor.**execute_kwargs: Additional options to pass tocursor.execute_async.
execute_many
operation: The SQL query or other operation to be executed.seq_of_parameters: The sequence of parameters for the operation.
execute_many_async
operation: The SQL query or other operation to be executed.seq_of_parameters: The sequence of parameters for the operation.
fetch_all
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.cursor_type: The class of the cursor to use when creating a Snowflake cursor.**execute_kwargs: Additional options to pass tocursor.execute_async.
- A list of tuples containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
fetch_all_async
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.cursor_type: The class of the cursor to use when creating a Snowflake cursor.**execute_kwargs: Additional options to pass tocursor.execute_async.
- A list of tuples containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
fetch_many
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.size: The number of results to return; if None or 0, uses the value offetch_sizeconfigured on the block.cursor_type: The class of the cursor to use when creating a Snowflake cursor.**execute_kwargs: Additional options to pass tocursor.execute_async.
- A list of tuples containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
fetch_many_async
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.size: The number of results to return; if None or 0, uses the value offetch_sizeconfigured on the block.cursor_type: The class of the cursor to use when creating a Snowflake cursor.**execute_kwargs: Additional options to pass tocursor.execute_async.
- A list of tuples containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
fetch_one
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.cursor_type: The class of the cursor to use when creating a Snowflake cursor.**execute_kwargs: Additional options to pass tocursor.execute_async.
- A tuple containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
fetch_one_async
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.cursor_type: The class of the cursor to use when creating a Snowflake cursor.**execute_kwargs: Additional options to pass tocursor.execute_async.
- A tuple containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
get_connection
**connect_kwargs: Additional arguments to pass tosnowflake.connector.connect.
- The authenticated SnowflakeConnection.