Save dataframe to postqresql and render it in html

I have a dataframe i want to save in postqresql and then access it and display in html and add some editable columns to it.Has any one had this kind of problem and how did you approach it

Hi @ekkpodogui

You need to give a bit of context on what you are trying to solve

Let’s assume you are building an app in Flask and want to the front end to display data in a html table fetching data from a psql database. However your original data is in a pandas dataframe and you need to populate the data into a psql db for more data persistence

if you already have a database instance running somewhere what I would do is

connect to the database using say sqlalcheme. There are many options here.
insert the data into the table you want. If you do not have a table then need to create one.

The the last part to create an app in Flask (for example) that connect to your db and then create a route that render the table. You can use Jinja2 template for that.

I developed an app that does kind of this

you can have a look at the app here and the code is in github

the template that renders html would look like this

hope this helps

if any queries let me know

Regards

Pedro

1 Like

So what i ma trying to solve is i have a dataframe i want to render in an html table which will allow a user to edit some columns and based on the 2 edited columns result a new column will be created and added to the dataframe also i am using django framework

Hi @ekkpodogui this looks like more of a javascrip challenge. I cannot help you but there may be a solution somewhere.

1 Like