Does "reference arguement passing mechanism" work with callback function?

Hi, Please look into the following code:
As we all know, there is a “reference parameter passing mechanism” for mutable variables like the following example:

a = [1,2,3]
def fun(x):
    x[0] = 3
    x[1] = 2
    x[2] = 1
print(a) # we get [1,2,3] here 
fun(a)
print(a) # we get [3,2,1] here
# So "reference parameters passing mechanism for mutable types" works here!

But, It seems like that this mechanism don’t work with streamlit callback functions which demonstrated in the following codes:

import streamlit as st
import pandas as pd
import mysql.connector

#define a global variable to contain mysql connection
db_connection = mysql.connector.MySQLConnection()

st.write(f'1:  {db_connection}')

#pass db_connection to callback function and mysql connection will be asigned to to db_connection
#but, the "reference parameter passing" mechanism seems don't work with callback function
#db_connection and conn are two different references here, but according "reference parameter passing", mutable arguements 
#can be modified within function body.
def get_db_connection(conn,host,port,user,database,password):
    try:
        conn = mysql.connector.connect(host=host,port=port,user=user, database=database,password=password)
        st.write(f'2:  {conn}')
    except Exception as e:
        st.write('Failed to Connect to Database! Try Again!')
        st.write(e)
        

sidebar_subtitle1 = st.sidebar.subheader('Connection to Database')
form_db_connection = st.sidebar.form('form_db_connection')
connection_status = form_db_connection.empty()
input_user_name = form_db_connection.text_input(label='Input DB User Name:')
input_db = form_db_connection.text_input(label='Input Database Name:')
input_pass = form_db_connection.text_input(label='Input Password', type='password')
input_db_host = form_db_connection.text_input(label='Input DB Server IP:')
input_db_port = form_db_connection.number_input(label='Input DB Server Port:',min_value=0,max_value=99999,value=3306,step=1)

#pass db_connection to callback function and mysql connection will be asigned to to db_connection
#but, the "reference parameter passing" mechanism seems don't work with callback function
#db_connection and conn are two different references here, but according "reference parameter passing", mutable arguements 
#can be modified within function body.
button_test_connection = form_db_connection.form_submit_button('Press to Connect', on_click=get_db_connection,  \
                        kwargs={'conn':db_connection,'host':input_db_host,'port':input_db_port,                   \
                                    'user':input_user_name, 'database':input_db, 'password':input_pass})

st.write(f'3:  {db_connection}')

What can I do to let streamlit callback function update a outside mutable variable?