SnowflakeConnector

Configuration

The arguments for the Snowflake connector are:

  • id: ID for your connector

  • user: the username to your Snowflake account

  • password: the password to your Snowflake account

  • account: the account name for your Snowflake account

  • role: the desired role for the connection

  • warehouse: the desired warehouse for the connection

  • database: the desired database for the connection

  • schema: the desired schema for the connection

snowflake_connector = SnowflakeConnector(
    id="snowflake_connector_id",
    user=os.environ["SNOWFLAKE_USER"],
    password=os.environ["SNOWFLAKE_PASSWORD"],
    account=os.environ["SNOWFLAKE_ACCOUNT"],
    role=os.environ["SNOWFLAKE_ROLE"],
    warehouse=os.environ["SNOWFLAKE_WAREHOUSE"],
    database=os.environ["SNOWFLAKE_DATABASE"],
    schema=os.environ["SNOWFLAKE_SCHEMA"],
)

Under the hood, Prism takes care of parsing the configuration variables and establishing a connection to your Snowflake account.

execute_sql

You can run queries against the Snowflake connection using the execute_sql function:

from prism.decorators import task
from prism.runtime import CurrentRun

@task()
def snowflake_task(self):
    conn = CurrentRun.conn("snowflake_connector_id")
    data = conn.execute_sql(
        sql="SELECT * FROM table"
    )

Note that when return_type = None, the result will be a list tuples containing the query data.

Last updated