How can I use Dash's DataTable to edit an SQL Database?

As the title suggests, my app contains a DataTable which reads from a database in an SQL Server using the pyodbc package. The user can edit the contents of the cells in the DataTable but I don’t know how to apply those changes into the database in the server.

Is this possible? If so, can you please show me how or guide me to helpful sources?

PS: I am a beginner in using Dash and its callbacks so anything will help.

Thanks!

Is your problem how to retrieve the user’s changes into a Python callback function, or is it how to update the database after you’ve done that?

If it’s the first, I’m not sure if there are any good code examples in the documentation using DataTable (perhaps others here can help?). The documentation for AG-Grid is much better than the doc for DataTable, and AG-Grid is also a much better component. Would it be possible for you to use Dash AG-Grid instead? (Ag-Grid doc including some code examples showing how to process user input is at: Editing and Callbacks | Dash for Python Documentation | Plotly)

1 Like

Yes, exactly. The goal is to retrieve the user’s changes into a Python callback function. The callback function should somehow apply those changes into the SQL database.

I just checked AG-Grid and it definitely looks like a better alternative to DataTable regarding functionality and aesthetics as well. The documentation gave me a couple of ideas that I’m curious to try.

Thank you, this was very helpful :raised_hands:

1 Like