How to do CRUD (add,delete,update) on dynamic datafram displayed using data_editor

HI,
I have some dataframes generated dynamically here’s the code:

def df_on_change():
          pass
 df=getAllData(userRole=st.session_state['role'],userId=st.session_state['userId'])
gp = df.groupby(["univertcity", "country", "sector"])
for key, item in gp:
    st.session_state.df=gp.get_group(key)    
    st.data_editor(st.session_state.df,use_container_width=True,
    ,on_change=df_on_change)

here’s the result :

now, the issue which I’m facing I have no idea how to add and update and delete for each datafram( on thebackgrounf i want to execute some sql queries to update the DB, i dont know how to play with collbacks to achieve this )

thanks a lot for your help