Registry / workflow / prefect-snowflake

prefect-snowflake

JSON →
library0.28.8pypypi✓ verified 85d ago

The `prefect-snowflake` library provides Prefect 2.x integrations for interacting with Snowflake, enabling users to define flows that connect to Snowflake databases, execute queries, and manage data. It currently ships as version 0.28.7 and follows the Prefect ecosystem's release cadence, often aligning with Prefect core releases.

pip install prefect-snowflake
INSTALL
IMPORT
SIG · PREFECT-SNOWFLAKE
P
prefect-snowflake
workflowpythonv0.28.8
Install
25.6s avg
Import
Disk
317MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.28.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 25.6s · import 0.000s · 320MB
317MB installed
● package 317MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SnowflakeConnector
from prefect_snowflake import SnowflakeConnector
from prefect_snowflake.connections import SnowflakeConnector
SnowflakeCredentials
from prefect_snowflake import SnowflakeCredentials
from prefect_snowflake.credentials import SnowflakeCredentials

This quickstart demonstrates how to create a `SnowflakeConnector` block programmatically, save it, load it, and use it within a Prefect flow to execute a Snowflake query. It uses environment variables for sensitive credentials and handles the synchronous nature of `snowflake-connector-python` within an async Prefect task.

import os import asyncio from prefect import flow, task from prefect_snowflake.connections import SnowflakeConnector @task async def run_snowflake_query(connector_block: SnowflakeConnector, query: str): """ Executes a Snowflake query using the provided connector block. """ # snowflake-connector-python is synchronous, so it must be run in a thread pool # when used within an async Prefect task/flow. async with connector_block.get_connection() as conn: result = await conn.run_sync(lambda c: c.cursor().execute(query).fetchall()) return result @flow async def snowflake_example_flow(query: str = "SELECT CURRENT_VERSION()"): """ An example Prefect flow that connects to Snowflake and runs a query. """ block_name = "my-snowflake-connector-agent" # Create and save a SnowflakeConnector block programmatically. # In a real-world scenario, you might load a pre-configured block # from the Prefect UI or directly pass connection details. connector = SnowflakeConnector( account=os.environ.get("SNOWFLAKE_ACCOUNT", "your_account_id"), user=os.environ.get("SNOWFLAKE_USER", "your_user"), password=os.environ.get("SNOWFLAKE_PASSWORD", "your_password"), warehouse=os.environ.get("SNOWFLAKE_WAREHOUSE", "your_warehouse"), database=os.environ.get("SNOWFLAKE_DATABASE", "your_database"), schema=os.environ.get("SNOWFLAKE_SCHEMA", "PUBLIC"), role=os.environ.get("SNOWFLAKE_ROLE", "PUBLIC"), ) # Save the block; overwrite if it already exists from a previous run await connector.save(block_name, overwrite=True) # Load the block (even if just saved, this is how you'd normally load it) snowflake_connector_block = await SnowflakeConnector.load(block_name) # Run the query task result = await run_snowflake_query(snowflake_connector_block, query) print(f"Snowflake Query Result for '{query}': {result}") if __name__ == "__main__": # To run this flow, ensure you have set the SNOWFLAKE_* environment variables # or replace the os.environ.get calls with actual credentials. # Example: # export SNOWFLAKE_ACCOUNT="YOUR_ACCOUNT.region.azure" (or just YOUR_ACCOUNT_NAME) # export SNOWFLAKE_USER="YOUR_USER" # export SNOWFLAKE_PASSWORD="YOUR_PASSWORD" # export SNOWFLAKE_WAREHOUSE="YOUR_WAREHOUSE" # export SNOWFLAKE_DATABASE="YOUR_DATABASE" # export SNOWFLAKE_SCHEMA="YOUR_SCHEMA" # export SNOWFLAKE_ROLE="YOUR_ROLE" # Run the flow (requires an event loop, so asyncio.run is appropriate for direct execution) asyncio.run(snowflake_example_flow())
Debug
Known issues
gotchaThe underlying `snowflake-connector-python` library is synchronous. When used within Prefect's async tasks and flows, it requires explicit handling (e.g., using `connection.run_sync` or wrapping synchronous code in `sync_compatible` or `task_run_sync`) to avoid blocking the event loop.
fix
Use `await conn.run_sync(...)` when performing synchronous Snowflake operations within an `async` Prefect task, or decorate synchronous tasks with `@task(log_prints=True)` which often handles this implicitly for simple cases.
affects: All versions
gotchaPrefect integrations often rely on Prefect Blocks to manage credentials and configuration. You must create and save a `SnowflakeConnector` block (either programmatically as in the quickstart, or via the Prefect UI/CLI) before you can load and use it in your flows.
fix
Ensure `await SnowflakeConnector(...).save('block-name', overwrite=True)` is called at least once, or that the block is configured in your Prefect environment, before attempting `await SnowflakeConnector.load('block-name')`.
affects: All versions
breaking`prefect-snowflake` is an integration for Prefect 2.x. It is not compatible with Prefect 1.x flows and APIs.
fix
Ensure your project is using Prefect 2.x (`prefect>=2.0`) and that your code adheres to Prefect 2.x patterns (e.g., `@flow`, `@task` decorators, async by default).
affects: All versions
gotchaThe `account` parameter for `SnowflakeConnector` can sometimes be tricky, requiring specific formats depending on your Snowflake region and cloud provider (e.g., `account_identifier.region.cloud_provider` or just `account_identifier`).
fix
Refer to the official Snowflake documentation for your specific account identifier format, or experiment with adding region/cloud provider suffixes (e.g., `.aws`, `.azure`, `.gcp`) if a simple account name doesn't work.
affects: All versions
Upgrade
Version history
0.28.8latest on PyPI · released Jun 5, 2026
Audit
Dependencies
prefectrequiredThis is a Prefect integration and requires Prefect core (2.x) to function.
snowflake-connector-pythonrequiredThis is the underlying Python driver used to connect to Snowflake.
Agent activity
37 hits · last 30 days
node
34
OpenAI (training)
1
Resources
prefect-snowflake — pip install prefect-snowflake · libregistry