The prefect-snowflake
integration makes it easy to connect to Snowflake in your Prefect flows. You can run queries both synchronously and asynchronously as Prefect flows and tasks.
Install prefect-snowflake
as a dependency of Prefect.
If you don’t already have Prefect installed, it will install the newest version of prefect
as well.
Upgrade to the latest versions of prefect
and prefect-snowflake
:
The prefect-snowflake
integration has two blocks: one for storing credentials and one for storing connection information. Register blocks in this module to view and edit them on Prefect Cloud:
Below is a walkthrough on saving a SnowflakeCredentials
block through code. Log into your Snowflake account to find your credentials.
The example below uses a user and password combination, but refer to the SDK documentation for a full list of authentication and connection options.
Then, to create a SnowflakeConnector
block:
You can now easily load the saved block, which holds your credentials and connection info:
To set up a table, use the execute
and execute_many
methods. Then, use the fetch_all
method. If the results are too large to fit into memory, use the fetch_many
method to retrieve data in chunks.
By using the SnowflakeConnector
as a context manager, you can make sure that the Snowflake connection and cursors are closed properly after you’re done with them.
If the native methods of the block don’t meet your requirements, don’t worry. You have the option to access the underlying Snowflake connection and utilize its built-in methods as well.
Refer to the prefect-snowflake
SDK documentation to explore other capabilities of the prefect-snowflake
library, such as async methods.
For further assistance using Snowflake, consult the Snowflake documentation or the Snowflake Python Connector documentation.
The prefect-snowflake
integration makes it easy to connect to Snowflake in your Prefect flows. You can run queries both synchronously and asynchronously as Prefect flows and tasks.
Install prefect-snowflake
as a dependency of Prefect.
If you don’t already have Prefect installed, it will install the newest version of prefect
as well.
Upgrade to the latest versions of prefect
and prefect-snowflake
:
The prefect-snowflake
integration has two blocks: one for storing credentials and one for storing connection information. Register blocks in this module to view and edit them on Prefect Cloud:
Below is a walkthrough on saving a SnowflakeCredentials
block through code. Log into your Snowflake account to find your credentials.
The example below uses a user and password combination, but refer to the SDK documentation for a full list of authentication and connection options.
Then, to create a SnowflakeConnector
block:
You can now easily load the saved block, which holds your credentials and connection info:
To set up a table, use the execute
and execute_many
methods. Then, use the fetch_all
method. If the results are too large to fit into memory, use the fetch_many
method to retrieve data in chunks.
By using the SnowflakeConnector
as a context manager, you can make sure that the Snowflake connection and cursors are closed properly after you’re done with them.
If the native methods of the block don’t meet your requirements, don’t worry. You have the option to access the underlying Snowflake connection and utilize its built-in methods as well.
Refer to the prefect-snowflake
SDK documentation to explore other capabilities of the prefect-snowflake
library, such as async methods.
For further assistance using Snowflake, consult the Snowflake documentation or the Snowflake Python Connector documentation.