I have a dataframe in postgres and I need to be able to edit a column which should be reflected in my dataframe. The column is in int. And I need to be able to change the values in that column. How can I do this
Welcome to the Streamlit community, @Ayman_Sharief!
Yes, editing a column in a DataFrame that’s stored in a PostgreSQL database from a Streamlit app is perfectly doable!
You need to install psycopg2-binary
for PostgreSQL database connection (pip install psycopg2-binary
). Here’s one way to establish a connection:
import psycopg2
def get_connection():
connection = psycopg2.connect(
host='your_host',
database='your_database',
user='your_user',
password='your_password')
return connection
Then define a function to return the connection object, load, and display the data back in Streamlit.
Let me know how it goes.
Best,
Charly
Oh @Ayman_Sharief there’s also this tutorial that you may find helpful!
Charly
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.