How to update database after edit st.aggrid

i am using the st_aggrid component with connection with database what i want is to allow the user user to edit a column value using st_aggrid than after edit is done its commit on the database how can i do this ?? because until now when user edit a value the database value doesn’t change.

code:

df = pd.read_sql_query("select * from app_db where user ='jasmin'",con)

gd=GridOptionsBuilder.from_dataframe(df)
gd.configure_column("status",editable = True)
gridoptions = gd.build()
grid_table = AgGrid(df,
                    gridOptions = gridoptions, 
                    update_mode = GridUpdateMode.SELECTION_CHANGED,
                    height = 500,
                    them = "fresh"
)

from here how to commit the update on the database??

you can update your db by checking for all changes between grid_table and original df
I do a df which I return all changes

    df_changes = grid_table[ ~grid_table[['IO_Num', 'RR.Done', 'IO.Comment']].apply(tuple,1).isin(df[['IO_Num', 'RR.Done', 'IO.Comment']].apply(tuple,1))].dropna()
1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.