import streamlit as st
import snowflake.connector
Initialize connection.
Uses st.cache to only run once.
@st.cache(allow_output_mutation=True, hash_funcs={"thread.RLock": lambda : None})
def init_connection():
    return snowflake.connector.connect(**st.secrets["snowflake"])
conn = init_connection()
Perform query.
Uses st.cache to only rerun when the query changes or after 10 min.
@st.cache(ttl=600)
def run_query(query):
    with conn.cursor() as cur:
        cur.execute(query)
        return cur.fetchall()
rows = run_query("SELECT * from mytable;")
Print results.
for row in rows:
    st.write(f"{row[0]} has a :{row[1]}:")
```
See st.cache above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With st.cache, it only runs when the query changes or after 10 minutes (that's what ttl is for). Watch out: If your database updates more frequently, you should adapt ttl or remove caching so viewers always see the latest data. Read more about caching here.
