\n\n", + "examples": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
\n\n", "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", + "examples": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
\n\n", "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", + "examples": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
\n\n", "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", + "examples": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
\n\n", "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", + "examples": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
\n\n", "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", + "examples": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
\n\n", "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", + "examples": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
\n\n", "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", - "description": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\n\n\n", + "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 3: Configuration with keyword arguments
\nYou can configure your SQL connection with keyword arguments (with or\nwithout secrets.toml). For example, if you use Microsoft Entra ID with\na Microsoft Azure SQL server, you can quickly set up a local connection for\ndevelopment using interactive authentication.
\nThis example requires the Microsoft ODBC Driver for SQL Server\nfor Windows in addition to the sqlalchemy and pyodbc packages for\nPython.
\n\nimport streamlit as st\n\nconn = st.connection(\n "sql",\n dialect="mssql",\n driver="pyodbc",\n host="xxx.database.windows.net",\n database="xxx",\n username="xxx",\n query={\n "driver": "ODBC Driver 18 for SQL Server",\n "authentication": "ActiveDirectoryInteractive",\n "encrypt": "yes",\n },\n)\n\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine.
\nInitialize this connection object using st.connection("sql") or\nst.connection("<name>", type="sql"). Connection parameters for a\nSQLConnection can be specified using secrets.toml and/or **kwargs.\nPossible connection parameters include:
\nIf url exists as a connection parameter, Streamlit will pass it to\nsqlalchemy.engine.make_url(). Otherwise, Streamlit requires (at a\nminimum) dialect, username, and host. Streamlit will use\ndialect and driver (if defined) to derive drivername, then pass\nthe relevant connection parameters to sqlalchemy.engine.URL.create().
\nIn addition to the default keyword arguments for sqlalchemy.create_engine(),\nyour dialect may accept additional keyword arguments. For example, if you\nuse dialect="snowflake" with Snowflake SQLAlchemy,\nyou can pass a value for private_key to use key-pair authentication. If\nyou use dialect="bigquery" with Google BigQuery,\nyou can pass a value for location.
\nSQLConnection provides the .query() convenience method, which can be\nused to run simple, read-only queries with both caching and simple error\nhandling/retries. More complex database interactions can be performed by\nusing the .session property to receive a regular SQLAlchemy Session.
\nImportant
\nSQLAlchemy must be installed\nin your environment to use this connection. You must also install your\ndriver, such as pyodbc or psycopg2.
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", - "description": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\n\n\n", + "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 3: Configuration with keyword arguments
\nYou can configure your SQL connection with keyword arguments (with or\nwithout secrets.toml). For example, if you use Microsoft Entra ID with\na Microsoft Azure SQL server, you can quickly set up a local connection for\ndevelopment using interactive authentication.
\nThis example requires the Microsoft ODBC Driver for SQL Server\nfor Windows in addition to the sqlalchemy and pyodbc packages for\nPython.
\n\nimport streamlit as st\n\nconn = st.connection(\n "sql",\n dialect="mssql",\n driver="pyodbc",\n host="xxx.database.windows.net",\n database="xxx",\n username="xxx",\n query={\n "driver": "ODBC Driver 18 for SQL Server",\n "authentication": "ActiveDirectoryInteractive",\n "encrypt": "yes",\n },\n)\n\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine.
\nInitialize this connection object using st.connection("sql") or\nst.connection("<name>", type="sql"). Connection parameters for a\nSQLConnection can be specified using secrets.toml and/or **kwargs.\nPossible connection parameters include:
\nIf url exists as a connection parameter, Streamlit will pass it to\nsqlalchemy.engine.make_url(). Otherwise, Streamlit requires (at a\nminimum) dialect, username, and host. Streamlit will use\ndialect and driver (if defined) to derive drivername, then pass\nthe relevant connection parameters to sqlalchemy.engine.URL.create().
\nIn addition to the default keyword arguments for sqlalchemy.create_engine(),\nyour dialect may accept additional keyword arguments. For example, if you\nuse dialect="snowflake" with Snowflake SQLAlchemy,\nyou can pass a value for private_key to use key-pair authentication. If\nyou use dialect="bigquery" with Google BigQuery,\nyou can pass a value for location.
\nSQLConnection provides the .query() convenience method, which can be\nused to run simple, read-only queries with both caching and simple error\nhandling/retries. More complex database interactions can be performed by\nusing the .session property to receive a regular SQLAlchemy Session.
\nImportant
\nSQLAlchemy must be installed\nin your environment to use this connection. You must also install your\ndriver, such as pyodbc or psycopg2.
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", - "description": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\n\n\n", + "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 3: Configuration with keyword arguments
\nYou can configure your SQL connection with keyword arguments (with or\nwithout secrets.toml). For example, if you use Microsoft Entra ID with\na Microsoft Azure SQL server, you can quickly set up a local connection for\ndevelopment using interactive authentication.
\nThis example requires the Microsoft ODBC Driver for SQL Server\nfor Windows in addition to the sqlalchemy and pyodbc packages for\nPython.
\n\nimport streamlit as st\n\nconn = st.connection(\n "sql",\n dialect="mssql",\n driver="pyodbc",\n host="xxx.database.windows.net",\n database="xxx",\n username="xxx",\n query={\n "driver": "ODBC Driver 18 for SQL Server",\n "authentication": "ActiveDirectoryInteractive",\n "encrypt": "yes",\n },\n)\n\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine.
\nInitialize this connection object using st.connection("sql") or\nst.connection("<name>", type="sql"). Connection parameters for a\nSQLConnection can be specified using secrets.toml and/or **kwargs.\nPossible connection parameters include:
\nIf url exists as a connection parameter, Streamlit will pass it to\nsqlalchemy.engine.make_url(). Otherwise, Streamlit requires (at a\nminimum) dialect, username, and host. Streamlit will use\ndialect and driver (if defined) to derive drivername, then pass\nthe relevant connection parameters to sqlalchemy.engine.URL.create().
\nIn addition to the default keyword arguments for sqlalchemy.create_engine(),\nyour dialect may accept additional keyword arguments. For example, if you\nuse dialect="snowflake" with Snowflake SQLAlchemy,\nyou can pass a value for private_key to use key-pair authentication. If\nyou use dialect="bigquery" with Google BigQuery,\nyou can pass a value for location.
\nSQLConnection provides the .query() convenience method, which can be\nused to run simple, read-only queries with both caching and simple error\nhandling/retries. More complex database interactions can be performed by\nusing the .session property to receive a regular SQLAlchemy Session.
\nImportant
\nSQLAlchemy must be installed\nin your environment to use this connection. You must also install your\ndriver, such as pyodbc or psycopg2.
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", - "description": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\n\n\n", + "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 3: Configuration with keyword arguments
\nYou can configure your SQL connection with keyword arguments (with or\nwithout secrets.toml). For example, if you use Microsoft Entra ID with\na Microsoft Azure SQL server, you can quickly set up a local connection for\ndevelopment using interactive authentication.
\nThis example requires the Microsoft ODBC Driver for SQL Server\nfor Windows in addition to the sqlalchemy and pyodbc packages for\nPython.
\n\nimport streamlit as st\n\nconn = st.connection(\n "sql",\n dialect="mssql",\n driver="pyodbc",\n host="xxx.database.windows.net",\n database="xxx",\n username="xxx",\n query={\n "driver": "ODBC Driver 18 for SQL Server",\n "authentication": "ActiveDirectoryInteractive",\n "encrypt": "yes",\n },\n)\n\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine.
\nInitialize this connection object using st.connection("sql") or\nst.connection("<name>", type="sql"). Connection parameters for a\nSQLConnection can be specified using secrets.toml and/or **kwargs.\nPossible connection parameters include:
\nIf url exists as a connection parameter, Streamlit will pass it to\nsqlalchemy.engine.make_url(). Otherwise, Streamlit requires (at a\nminimum) dialect, username, and host. Streamlit will use\ndialect and driver (if defined) to derive drivername, then pass\nthe relevant connection parameters to sqlalchemy.engine.URL.create().
\nIn addition to the default keyword arguments for sqlalchemy.create_engine(),\nyour dialect may accept additional keyword arguments. For example, if you\nuse dialect="snowflake" with Snowflake SQLAlchemy,\nyou can pass a value for private_key to use key-pair authentication. If\nyou use dialect="bigquery" with Google BigQuery,\nyou can pass a value for location.
\nSQLConnection provides the .query() convenience method, which can be\nused to run simple, read-only queries with both caching and simple error\nhandling/retries. More complex database interactions can be performed by\nusing the .session property to receive a regular SQLAlchemy Session.
\nImportant
\nSQLAlchemy must be installed\nin your environment to use this connection. You must also install your\ndriver, such as pyodbc or psycopg2.
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n\n\n", - "description": "\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("select * from pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine. Initialize using st.connection("<name>", type="sql").
\nSQLConnection provides the query() convenience method, which can be used to\nrun simple read-only queries with both caching and simple error handling/retries.\nMore complex DB interactions can be performed by using the .session property\nto receive a regular SQLAlchemy Session.
\nSQLConnections should always be created using st.connection(), not\ninitialized directly. Connection parameters for a SQLConnection can be specified\nusing either st.secrets or **kwargs. Some frequently used parameters include:
\n\n\n", + "description": "Example 1: Configuration with URL
\nYou can configure your SQL connection using Streamlit's\nSecrets management.\nThe following example specifies a SQL connection URL.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\nurl = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 2: Configuration with dialect, host, and username
\nIf you do not specify url, you must at least specify dialect,\nhost, and username instead. The following example also includes\npassword.
\n.streamlit/secrets.toml:
\n\n[connections.sql]\ndialect = "xxx"\nhost = "xxx"\nusername = "xxx"\npassword = "xxx"\n\nYour app code:
\n\nimport streamlit as st\n\nconn = st.connection("sql")\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\nExample 3: Configuration with keyword arguments
\nYou can configure your SQL connection with keyword arguments (with or\nwithout secrets.toml). For example, if you use Microsoft Entra ID with\na Microsoft Azure SQL server, you can quickly set up a local connection for\ndevelopment using interactive authentication.
\nThis example requires the Microsoft ODBC Driver for SQL Server\nfor Windows in addition to the sqlalchemy and pyodbc packages for\nPython.
\n\nimport streamlit as st\n\nconn = st.connection(\n "sql",\n dialect="mssql",\n driver="pyodbc",\n host="xxx.database.windows.net",\n database="xxx",\n username="xxx",\n query={\n "driver": "ODBC Driver 18 for SQL Server",\n "authentication": "ActiveDirectoryInteractive",\n "encrypt": "yes",\n },\n)\n\ndf = conn.query("SELECT * FROM pet_owners")\nst.dataframe(df)\n\n
A connection to a SQL database using a SQLAlchemy Engine.
\nInitialize this connection object using st.connection("sql") or\nst.connection("<name>", type="sql"). Connection parameters for a\nSQLConnection can be specified using secrets.toml and/or **kwargs.\nPossible connection parameters include:
\nIf url exists as a connection parameter, Streamlit will pass it to\nsqlalchemy.engine.make_url(). Otherwise, Streamlit requires (at a\nminimum) dialect, username, and host. Streamlit will use\ndialect and driver (if defined) to derive drivername, then pass\nthe relevant connection parameters to sqlalchemy.engine.URL.create().
\nIn addition to the default keyword arguments for sqlalchemy.create_engine(),\nyour dialect may accept additional keyword arguments. For example, if you\nuse dialect="snowflake" with Snowflake SQLAlchemy,\nyou can pass a value for private_key to use key-pair authentication. If\nyou use dialect="bigquery" with Google BigQuery,\nyou can pass a value for location.
\nSQLConnection provides the .query() convenience method, which can be\nused to run simple, read-only queries with both caching and simple error\nhandling/retries. More complex database interactions can be performed by\nusing the .session property to receive a regular SQLAlchemy Session.
\nImportant
\nSQLAlchemy must be installed\nin your environment to use this connection. You must also install your\ndriver, such as pyodbc or psycopg2.
\nA connection to Snowflake using the Snowflake Python Connector. Initialize using
\nst.connection("<name>", type="snowflake").
\nSnowflakeConnection supports direct SQL querying using .query("..."), access to\nthe underlying Snowflake Python Connector object with .raw_connection, and other\nconvenience functions. See the methods below for more information.\nSnowflakeConnections should always be created using st.connection(), not\ninitialized directly.
\n", + "examples": "\n\n", + "description": "Example 1: Configuration with Streamlit secrets
\nYou can configure your Snowflake connection using Streamlit's\nSecrets management.\nFor example, if you have MFA enabled on your account, you can connect using\nkey-pair authentication.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\naccount = "xxx-xxx"\nuser = "xxx"\nprivate_key_file = "/xxx/xxx/xxx.p8"\nrole = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 2: Configuration with keyword arguments and external authentication
\nYou can configure your Snowflake connection with keyword arguments (with or\nwithout secrets.toml). For example, if your Snowflake account supports\nSSO, you can set up a quick local connection for development using browser-based SSO.
\n\nimport streamlit as st\nconn = st.connection(\n "snowflake", account="xxx-xxx", user="xxx", authenticator="externalbrowser"\n)\ndf = conn.query("SELECT * FROM my_table")\n\nExample 3: Named connection with Snowflake's connection configuration file
\nSnowflake's Python Connector supports a connection configuration file,\nwhich is well integrated with Streamlit's SnowflakeConnection. If you\nalready have one or more connections configured, all you need to do is pass\nthe name of the connection to use.
\n~/.snowflake/connections.toml:
\n\n[my_connection]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("my_connection", type="snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 4: Named connection with Streamlit secrets and Snowflake's connection configuration file
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can pass the connection name through\nsecrets.toml.
\n.streamlit/secrets.toml:
\n\n[connections.snowflake]\nconnection_name = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 5: Default connection with an environment variable
\nIf you have a Snowflake configuration file with a connection named\nmy_connection as in Example 3, you can set an environment variable to\ndeclare it as the default Snowflake connection.
\n\nSNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\nExample 6: Default connection in Snowflake's connection configuration file
\nIf you have a Snowflake configuration file that defines your default\nconnection, Streamlit will automatically use it if no other connection is\ndeclared.
\n~/.snowflake/connections.toml:
\n\n[default]\naccount = "xxx-xxx"\nuser = "xxx"\npassword = "xxx"\nwarehouse = "xxx"\ndatabase = "xxx"\nschema = "xxx"\n\nYour app code:
\n\nimport streamlit as st\nconn = st.connection("snowflake")\ndf = conn.query("SELECT * FROM my_table")\n\n
A connection to Snowflake using the Snowflake Connector for Python.
\nInitialize this connection object using st.connection("snowflake") or\nst.connection("<name>", type="snowflake"). Connection parameters for a\nSnowflakeConnection can be specified using secrets.toml and/or\n**kwargs. Connection parameters are passed to\nsnowflake.connector.connect().
\nWhen an app is running in Streamlit in Snowflake,\nst.connection("snowflake") connects automatically using the app owner's\nrole without further configuration. **kwargs will be ignored in this\ncase. Use secrets.toml and **kwargs to configure your connection\nfor local development.
\nSnowflakeConnection includes several convenience methods. For example, you\ncan directly execute a SQL query with .query() or access the underlying\nSnowflake Connector object with .raw_connection.
\nTip
\nsnowflake-snowpark-python\nmust be installed in your environment to use this connection. You can\ninstall Snowflake extras along with Streamlit:
\n\n>>> pip install streamlit[snowflake]\n\n
Important
\nAccount identifiers must be of the form <orgname>-<account_name>\nwhere <orgname> is the name of your Snowflake organization and\n<account_name> is the unique name of your account within your\norganization. This is dash-separated, not dot-separated like when used\nin SQL queries. For more information, see Account identifiers.
\n