Erik Osinga
05/14/2024, 5:47 PMMarvin
05/14/2024, 5:48 PMsnowflake_multiquery
function within a Prefect flow if you're using Snowflake as your database:
python
from prefect import flow
from prefect_snowflake.credentials import SnowflakeCredentials
from prefect_snowflake.database import SnowflakeConnector, snowflake_multiquery
@flow
def snowflake_multiquery_flow():
snowflake_credentials = SnowflakeCredentials(
account="account",
user="user",
password="password",
)
snowflake_connector = SnowflakeConnector(
database="database",
warehouse="warehouse",
schema="schema",
credentials=snowflake_credentials
)
result = snowflake_multiquery(
["SELECT * FROM table WHERE id=%{id_param}s LIMIT 8;", "SELECT 1,2"],
snowflake_connector,
params={"id_param": 1},
as_transaction=True
)
return result
snowflake_multiquery_flow()
You can adjust the example to fit the specifics of your database and what information you are querying for. Please replace "account"
, "user"
, "password"
, "database"
, "warehouse"
, "schema"
, and the SQL query as per your needs. The example is specific to Snowflake, so if you're using a different database, you'll need to construct a similar query using the relevant library or connector for that database.
You can read more about using Snowflake with Prefect in the documentation.
And if you are interested in understanding how flow runs are deployed and executed within Prefect, you might want to visit the Prefect blocks and deployments documentation.Nate
05/14/2024, 5:50 PMNate
05/14/2024, 5:50 PMread_flow_runs
client method that accepts a flow_run_filterNate
05/14/2024, 5:50 PMErik Osinga
05/14/2024, 5:53 PMErik Osinga
05/14/2024, 5:53 PM