Don't reconnect to the server

hi all.
I want to write a simple program with entering data through streamlit and sending this data to CasparCG. but when editing the data, I reconnect to the CasparCG server. how can i solve this problem?
short video

import streamlit as st
import pandas as pd
from amcp_pylib.core import Client

if st.checkbox("Подключиться"):
    connection = Client()
    connection.connect("", 5250)
    st.success("Соединение установлено")
    is_connected = True

def load_data(uploaded_file):
    df = pd.read_excel(uploaded_file)
    return df

placeholder = st.empty()
with placeholder.container():
    tab1, tab2 = st.tabs(["Редактор", "Титры"])
    with tab1:
        col1, col2 = st.columns((3, 7))
        with col1:
            uploaded_file = st.file_uploader(
                "Choose a Excel file", type="xlsx", accept_multiple_files=False

        with col2:
            if uploaded_file is not None:
                df = load_data(uploaded_file)
                # df = pd.read_excel(uploaded_file)
                df = pd.DataFrame(
                            "Имя + Фамилия / Никнейм": "",
                            "instagtam/telegram/youtube": "",
                            "Команда/амплуа": "",
                            "Выбрать": False,
            # print(df["Команда/амплуа"].unique())
            teams_temp = df["Команда/амплуа"].unique()
            teams_new = []
            for team1 in teams:
                if team1 in teams_temp:
            df["Команда/амплуа"] = (
            edited_df = st.experimental_data_editor(df, num_rows="dynamic", height=600)
            category = edited_df["Команда/амплуа"].unique()

        with col1:
            # buffer to use for excel writer
            buffer = io.BytesIO()

            # download button 2 to download dataframe as xlsx
            with pd.ExcelWriter(buffer, engine="xlsxwriter") as writer:
                edited_df.to_excel(writer, sheet_name="Sheet1", index=False)
                # writer.close()

                download2 = st.download_button(
                    label="Download data as Excel",

    with tab2:
        col1, col2 = st.columns((1, 9))
        with col1:
            option = st.selectbox("Команда", sorted(category))
        with col2:
            edited_df = st.experimental_data_editor(
                edited_df.loc[edited_df["Команда/амплуа"] == option],

Thank you

Hi there,

Thanks for sharing your question with the community!

Please check out our guidelines on how to post an effective question here and update your post to include a runnable code snippet so community members can make helpful suggestions :blush: