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, pass a config object to create_engine():

from adbc_poolhouse import SnowflakeConfig

from semolina import register, create_engine

engine = create_engine(
    SnowflakeConfig(
        account="xy12345.us-east-1",
        user="myuser",
        password="mypassword",
        database="analytics",
        warehouse="compute_wh",
    )
)
register("default", engine)

Run a query

Once an engine 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