Integrations
Integrate with Snowflake.
Chalk supports Snowflake as a SQL source.
You can configure the Snowflake-specific options using the SnowflakeSource.__init__
args.
Alternately, you can configure the source through your dashboard.
Add a Snowflake integration. These parameters will also be available as environment variables.
If you have only one Snowflake connection that you’d like to add to Chalk, you do not need to specify any arguments to construct the source in your code.
from chalk.sql import SnowflakeSource
snowflake = SnowflakeSource()
@online
def fn(...) -> ...:
return snowflake.query(...).first()
from chalk.sql import SnowflakeSource
risk = SnowflakeSource(name="RISK")
marketing = SnowflakeSource(name="MARKETING")
@online
def risk_resolver(...) -> ...:
return risk.query(...).first()
@online
def marketing_resolver(...) -> ...:
return marketing.query(...).first()
Named integrations inject environment variables with the standard names prefixed by the integration name. For example, if your integration is called RISK
, then the variable SNOWSQL_SCHEMA
will be injected as RISK_SNOWSQL_SCHEMA
. The first integration of a given kind will also create the un-prefixed environment variable (ie. both SNOWSQL_SCHEMA
and RISK_SNOWSQL_SCHEMA
).You can also configure the integration directly using environment variables on your local machine or from those added through the generic environment variable support.
import os
from chalk.sql import SnowflakeSource
snowflake = SnowflakeSource(
db=os.getenv("SNOWSQL_DATABASE"),
schema=os.getenv("SNOWSQL_SCHEMA"),
role=os.getenv("SNOWSQL_ROLE"),
warehouse=os.getenv("SNOWSQL_WAREHOUSE"),
user=os.getenv("SNOWSQL_USER"),
password=os.getenv("SNOWSQL_PWD"),
account_identifier=os.getenv("SNOWSQL_ACCOUNT_IDENTIFIER")
)
@online
def resolver_fn(...) -> ...:
return snowflake.query(...).first()