Spaces:
Sleeping
Sleeping
File size: 3,735 Bytes
746d2f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
---
title: st.connections.SnowflakeConnection
slug: /develop/api-reference/connections/st.connections.snowflakeconnection
---
<Tip>
This page only contains the `st.connections.SnowflakeConnection` class. For a deeper dive into creating and managing data connections within Streamlit apps, read [Connecting to data](/develop/concepts/connections/connecting-to-data).
</Tip>
<Autofunction function="streamlit.connections.SnowflakeConnection" />
### Configuration
{/**
Internal note: This section is deep-linked from the library in 1.28.1 via /st.connections.snowflakeconnection-configuration through a redirect.
Maintain the redirect if moved or modified.
**/}
`st.connection("snowflake")` can be configured using [Streamlit secrets](/develop/concepts/connections/secrets-management) or keyword args just like any other connection. It can also use existing Snowflake connection configuration when available.
Note that [snowflake-snowpark-python](https://pypi.org/project/snowflake-snowpark-python/) must be installed to use this connection.
#### Using Streamlit secrets
For example, if your Snowflake account supports SSO, you can set up a quick local connection for development using [browser-based SSO](https://docs.snowflake.com/en/user-guide/admin-security-fed-auth-use#how-browser-based-sso-works) and `secrets.toml` as follows:
```toml
# .streamlit/secrets.toml
[connections.snowflake]
account = "<ACCOUNT ID>"
user = "<USERNAME>"
authenticator = "EXTERNALBROWSER"
```
Learn more about [account indentifier here](https://docs.snowflake.com/en/user-guide/admin-account-identifier). You could also specify the full configuration and credentials in your secrets file, as in the [example here](/develop/tutorials/databases/snowflake#add-connection-parameters-to-your-local-app-secrets).
#### Using existing Snowflake configuration
Snowflake's python driver also supports a [connection configuration file](https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example#connecting-using-the-connections-toml-file), which is well integrated with Streamlit `SnowflakeConnection`. If you already have one or more connections configured, all you need to do is pass Streamlit the name of the connection to use. This can be done in several ways:
- Set `connection_name` in your app code, such as `st.connnection("<name>", type="snowflake")`.
- Set `connection_name = "<name>"` in the `[connections.snowflake]` section of your Streamlit secrets.
- Set the environment variable `SNOWFLAKE_DEFAULT_CONNECTION_NAME=<name>`.
- [Set a default connection](https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example#setting-a-default-connection) in your Snowflake configuration.
When available in [Streamlit in Snowflake](https://docs.snowflake.com/en/developer-guide/streamlit/about-streamlit), `st.connection("snowflake")` will connect automatically using the [app owner role](https://docs.snowflake.com/en/developer-guide/streamlit/owners-rights) and does not require any configuration.
Learn more about setting up connections in the [Connecting Streamlit to Snowflake tutorial](/develop/tutorials/databases/snowflake) and [Connecting to data](/develop/concepts/connections/connecting-to-data).
<Autofunction function="streamlit.connections.SnowflakeConnection.cursor" />
<Autofunction function="streamlit.connections.SnowflakeConnection.query" />
<Autofunction function="streamlit.connections.SnowflakeConnection.raw_connection" />
<Autofunction function="streamlit.connections.SnowflakeConnection.reset" />
<Autofunction function="streamlit.connections.SnowflakeConnection.session" />
<Autofunction function="streamlit.connections.SnowflakeConnection.write_pandas" />
|