I’ve built a dash app which takes inputs and does some calculations and prints some text. I now want to connect dash to SQL(I am currently using MySQL workbench on my windows 10 laptop) to store inputs from dash app after submit button. Has anyone done this or how do i go about doing it?
Yes, this is possible.
You gonna need a few things. I personally work with SqlAlchemy, Pandas and a few callbacks.
I don’t have a simple script for you, but I can explain the steps.
- First make sure you have a connection with the database by using SqlAlchemy.
- Your already do some calculations and print some text. So your already have a function. Expand this function to store these calculations and text in for instance a Pandas dataframe.
- Next, create a callback that is triggered by pressing the button. This buttons sends the data to the database. You can do this with the ‘df.to_sql()’ function of Pandas.
So I advice you to learn about Pandas (to_sql) and SqlAlchemy (or perhaps you already know this).
P.S. Setting up the connection with the database was a hassle for me the first time.
If you need anymore help, let me know.
will sure try it. I’m sure i’m gonna have more doubts.