Documentation

search

Search

Ctrl-K

Change to dark mode

  • rocket_launch

    Get started

    • Installation
      add
    • Fundamentals
      add
    • First steps
      add
  • code

    Develop

    • Concepts
      add
    • API reference
      remove
      • PAGE ELEMENTS
      • Write and magic
        add
      • Text elements
        add
      • Data elements
        add
      • Chart elements
        add
      • Input widgets
        add
      • Media elements
        add
      • Layouts and containers
        add
      • Chat elements
        add
      • Status elements
        add
      • Third-party componentsopen_in_new
      • APPLICATION LOGIC
      • Authentication and user info
        add
      • Navigation and pages
        add
      • Execution flow
        add
      • Caching and state
        add
      • Connections and secrets
        remove
        • SECRETS
        • st.secrets
        • secrets.toml
        • CONNECTIONS
        • st.connection
        • SnowflakeConnection
        • SQLConnection
        • BaseConnection
        • SnowparkConnectiondelete
      • Custom components
        add
      • Configuration
        add
      • TOOLS
      • App testing
        add
      • Command line
        add
    • Tutorials
      add
    • Quick reference
      add
  • web_asset

    Deploy

    • Concepts
      add
    • Streamlit Community Cloud
      add
    • Snowflake
    • Other platforms
      add
  • school

    Knowledge base

    • FAQ
    • Installing dependencies
    • Deployment issues
  • Home/
  • Develop/
  • API reference/
  • Connections and secrets
  1. Contents
  2. Setup your connection
  3. Built-in connections
  4. Third-party connections
  5. Secrets
  6. Deprecated classes

Connections and databases

Setup your connection

screenshot

Create a connection

Connect to a data source or API

conn = st.connection('pets_db', type='sql') pet_owners = conn.query('select * from pet_owners') st.dataframe(pet_owners)

Built-in connections

screenshot

SnowflakeConnection

A connection to Snowflake.

conn = st.connection('snowflake')
screenshot

SQLConnection

A connection to a SQL database using SQLAlchemy.

conn = st.connection('sql')

Third-party connections

Connection base class

Build your own connection with BaseConnection.

class MyConnection(BaseConnection[myconn.MyConnection]): def _connect(self, **kwargs) -> MyConnection: return myconn.connect(**self._secrets, **kwargs) def query(self, query): return self._instance.query(query)

Secrets

Secrets singleton

Access secrets from a local TOML file.

key = st.secrets["OpenAI_key"]

Secrets file

Save your secrets in a per-project or per-profile TOML file.

OpenAI_key = "<YOUR_SECRET_KEY>"

Deprecated classes

delete

SnowparkConnection

A connection to Snowflake.

conn = st.connection("snowpark")
arrow_backPrevious: Caching and statearrow_forwardNext: st.secrets
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.


HomeContact UsCommunity
© 2025 Snowflake Inc.