This code:
import pandas as pd
import plotly.express as px
import streamlit as st@st.cache(allow_output_mutation=True)
def get_data():
df = pd.read_sql(‘diesel-price-by-regions’, ‘string-LINK-to-cloud-POSTGRES’)
return dfdf = get_data()
#prepare thr chart
fig = px.line(df, x=‘date’, y=‘diesel_price’, color=‘region’,
title=‘Diesel price in the US’,
labels={‘date’:‘Date’,
‘diesel_price’:‘Price ($)’, ‘region’:‘Region’})fig.update_layout(legend=dict(
yanchor=“top”,
y=0.99,
xanchor=“left”,
x=0.01
))st.plotly_chart(fig)
Returns
File “/home/appuser/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py”, line 548, in create_engine
dbapi = dialect_cls.dbapi(**dbapi_args)
File “/home/appuser/venv/lib/python3.10/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py”, line 811, in dbapi
import psycopg2
ModuleNotFoundError: No module named ‘psycopg2’
I saw many topics about the same issue but did understand the way to pull data from the cloud postgress without psycopg2.
How to deal with it?