Skip to content

Snowflake

exportbadge

Introduced in v4.0

The Snowflake backend is experimental and is subject to backwards incompatible changes.

ibis.memtable Support memtable

The Snowflake backend supports memtables by natively executing queries against the underlying storage (e.g., pyarrow Tables or pandas DataFrames).

Install

Install ibis and dependencies for the Snowflake backend:

pip install 'ibis-framework[snowflake]'
conda install -c conda-forge ibis-snowflake
mamba install -c conda-forge ibis-snowflake

Connect

ibis.snowflake.connect

con = ibis.snowflake.connect(
    user="user",
    password="password",
    account="safpqpq-sq55555",
    database="IBIS_TESTING/IBIS_TESTING",
)

ibis.snowflake.connect is a thin wrapper around ibis.backends.snowflake.Backend.do_connect.

Connection Parameters

do_connect(user, account, database, password=None, authenticator=None, connect_args=None, **kwargs)

Connect to Snowflake.

Parameters:

Name Type Description Default
user str

Username

required
account str

A Snowflake organization ID and a Snowflake user ID, separated by a hyphen. Note that a Snowflake user ID is a separate identifier from a username. See https://ibis-project.org/backends/Snowflake/ for details

required
database str

A Snowflake database and a Snowflake schema, separated by a /. See https://ibis-project.org/backends/Snowflake/ for details

required
password str | None

Password. If empty or None then authenticator must be passed.

None
authenticator str | None

String indicating authentication method. See https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example#connecting-with-oauth for details.

Note that the authentication flow will not take place until a database connection is made. This means that ibis.snowflake.connect(...) can succeed, while subsequent API calls fail if the authentication fails for any reason.

None
connect_args Mapping[str, Any] | None

Additional arguments passed to the SQLAlchemy engine creation call.

None
kwargs Any

Additional arguments passed to the SQLAlchemy URL constructor. See https://docs.snowflake.com/en/developer-guide/python-connector/sqlalchemy#additional-connection-parameters for more details

{}

ibis.connect URL format

In addition to ibis.snowflake.connect, you can also connect to Snowflake by passing a properly formatted Snowflake connection URL to ibis.connect

con = ibis.connect(f"snowflake://{user}:{password}@{account}/{database}")

Authenticating with SSO

Ibis supports connecting to SSO-enabled Snowflake warehouses using the authenticator parameter.

You can use it in the explicit-parameters-style or in the URL-style connection APIs. All values of authenticator are supported.

Explicit

con = ibis.snowflake.connect(
    user="user",
    account="safpqpq-sq55555",
    database="my_database/my_schema",
    warehouse="my_warehouse",
    authenticator="externalbrowser",
)

URL

con = ibis.connect(
    f"snowflake://{user}@{account}/{database}?warehouse={warehouse}",
    authenticator="externalbrowser",
)

Looking up your Snowflake organization ID and user ID

A Snowflake account identifier consists of an organization ID and a user ID, separated by a hyphen.

This user ID is not the same as the username you log in with.

To find your organization ID and user ID, log in to the Snowflake web app, then click on the text just to the right of the Snowflake logo (in the lower-left-hand corner of the screen).

The bold text at the top of the little pop-up window is your organization ID. The bold blue text with a checkmark next to it is your user ID.

Snowflake Organization and User ID

Choosing a value for database

Snowflake refers to a collection of tables as a schema, and a collection of schema as a database.

You must choose a database and a schema to connect to. You can refer to the available databases and schema in the "Data" sidebar item in the Snowflake web app.

Snowflake Database


Last update: August 1, 2023