How to use caching to connect to sql server

i have the following code
df = pd.read_sql (sql, conn)

where sql is a SQL script and conn is an ODBC connection created with pymssql
the script normally returns a dataframe

how I can use streamlit caching
I could not find any simple example demoing this

Hi @Dragos_Boros, welcome to the Streamlit community!

You need to define anything you want to be cached in a function

@st.cache()
def get_df(sql, conn):
    return pd.read_sql (sql, conn)

df = get_df(sql, conn)

Best,
Randy