Could anyone share with me information they found useful for learning how to take inputs from Dash and save to a SQL database. The database structure has already been created.
Thanks!
Could anyone share with me information they found useful for learning how to take inputs from Dash and save to a SQL database. The database structure has already been created.
Thanks!
Hello @bpolasek,
There are a few ways:
You can save a dataframe directly to sql using df.to_sql.
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_sql.html
You can hook up to PostgreSQL and push updates that way:
Or, if you want transactions and SQL strings, you can use a library like pyodbc.
I personally use the last option, as I do some pretty extensive updates to a SQL server.
Yeah so I have been reading in data from a SQL database to generate graphs. Now I need to save some settings from these graphs into different SQL database tables. The current SQL set up uses pyodbc so I’m sure that is probably what I need to go for here.
In that case, you can create a cursor and perform an execute a raw SQL could with your updates.
Remember, do not take user’s inputs directly, but use ? as a placeholder.
Also, do not forget to commit after you are done.
Thank you!