How to connect to Snowflake

Install the Snowflake extra

pip install semolina[snowflake]
# or
uv add "semolina[snowflake]"

The Snowflake extra installs adbc-poolhouse[snowflake], which provides the ADBC Snowflake driver and connection pooling.

Configure manually

When credentials come from a vault or secrets manager, construct the pool directly:

from adbc_poolhouse import SnowflakeConfig, create_pool
from semolina import register

config = SnowflakeConfig(
    account="xy12345.us-east-1",
    user="myuser",
    password="mypassword",
    database="analytics",
    warehouse="compute_wh",
)
pool = create_pool(config)
register("default", pool, dialect="snowflake")

Run a query

Once a pool is registered, the query API works the same as any backend:

from semolina import SemanticView, Metric, Dimension


class Sales(SemanticView, view="sales"):
    revenue = Metric()
    country = Dimension()


cursor = (
    Sales.query()
    .metrics(Sales.revenue)
    .dimensions(Sales.country)
    .execute()
)
for row in cursor.fetchall_rows():
    print(row.country, row.revenue)

Generated SQL

Snowflake SQL uses AGG() for metrics and double-quoted identifiers:

SELECT AGG("revenue"), "country"
FROM "sales"
GROUP BY ALL

See also