# Update DataTable, store information in the Database and reload layout with new data

**URL:** <https://community.plotly.com/t/update-datatable-store-information-in-the-database-and-reload-layout-with-new-data/46308>\
**Category:** Dash Python\
**Created:** [October 21, 2020, 1:05pm UTC](https://community.plotly.com/t/update-datatable-store-information-in-the-database-and-reload-layout-with-new-data/46308 "2020-10-21T13:05:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![F00TPRiiNT](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@F00TPRiiNT](https://community.plotly.com/u/F00TPRiiNT)\
**Post date:** [October 21, 2020, 1:05pm UTC](https://community.plotly.com/t/update-datatable-store-information-in-the-database-and-reload-layout-with-new-data/46308/1 "2020-10-21T13:05:00Z")

</div>

Hey guys,  
I’m currently building my first dash app which also features user managment.  
Now I also want to integrate the possibility to amend user information which is shown in a datatable on the admin page. With the following code I already managed to update the database as soon as the table is altered, however, once i leave the admin page and go back to it the table doesn’t fetch the updated database data but instead the old data before the change. Is there a way to get the layout to reload the data from the database once it’s been updated?

```auto
def UpdateAdminRights(app):
    @app.callback(
        Output('users', 'data'),
        [Input('users', 'data_timestamp')],
        [State('users', 'data')])
    def display_output(timestamp, df):
        old = show_users() #connects to the DB and fetches information
        changed_user = [change for user, change in zip(old,df) if user != change]
        if changed_user:
            username = changed_user[0]['username']
            email = changed_user[0]['email']
            admin = 1 if changed_user[0]['admin'] == "True" else 0
            update_user(username, email, admin) #connects to the DB and updates information
        return df

```

It’s triggered as soon as this table is altered:

```auto
            dbc.Container([
                html.H3('View Users'),
                html.Hr(),
                dbc.Row([
                    dbc.Col([
                        dt.DataTable(
                            id='users',
                            columns = [{'name' : 'ID', 'id' : 'id'},
                                        {'name' : 'Username', 'id' : 'username'},
                                        {'name' : 'Email', 'id' : 'email'},
                                        {'name' : 'Admin', 'id' : 'admin'}],
                            data=show_users(),
                            editable = True,
                        ),
                    ], md=12, className = 'twelve columns'),
                ]),
            ], className='pretty_container')

```
