Updating database with data table

Hi All,
I’m trying to build simple data table layout in dash so I could edit values of my table in Postgress database.
My approach is to get active_cell and whenever it’s changed it triggers for sqalchemy to update that cell in database…
and… it’s not working… simply after clicking"ENTER" I get not value I just edited but value of new cell I’m getting into after enter clicked…
I’m a complete new to prog

raming and thought dash is the simplest way to program my database frontend…but it’s not so .
I looked for any solution in this forum but hadn’t found any…
any solution will be appreciated…

@app.callback(
    Output(
        'table-invoicing','data'
    ),
    [Input(
        'table-invoicing','active_cell'
    ),
    Input(
        'table-invoicing', 'data'
    ),
    State(
        'table-invoicing', 'data_previous'
    )]
)

def update_table_invoicing_kellner(active_cell,data,data_previous):
    df = pd.DataFrame(data)
    df.index +=1
    df['acceptance_date'] = pd.to_datetime(df['acceptance_date']).dt.date
    # print(df.info()) set search_path to reporting;
    if active_cell:
        if data is not None and data != data_previous:
            # time.sleep(1)
            cell_data = df.iloc[active_cell['row']][active_cell['column']]
            update_statement = f'set search_path to reporting; Update fakturowanie_kellner  SET {active_cell["column_id"]} = \'{cell_data}\' WHERE id = {active_cell["row"]+1};'
            print(update_statement)
            conn.execute(sql_text(update_statement))
            conn.commit()
            # df = pd.read_sql_query(con=conn, sql=sql_text(query))
            # return df.to_dict('records')
    return df.to_dict('records')