Add mysql-connector-python to your requirements file
Add the mysql-connector-python package to your requirements.txt file, preferably pinning its version (replace x.x.x with the version you want installed):
```bash
requirements.txt
mysql-connector-python==x.x.x
```
Write your Streamlit app
Copy the code below to your Streamlit app and run it. Make sure to adapt query to use the name of your table.
```python
streamlit_app.py
import streamlit as st
import mysql.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 mysql.connector.connect(**st.secrets["mysql"])
conn = init_connection()
Perform query.
Uses st.cache to only rerun when the query changes or after 10 min.
@st.cache(ttl=600)
