Two different ways to grab a dataframe from a postgresql database using python. I prefer the first, but am warming to the second.


from sqlalchemy import create_engine
import pandas as pd
import psycopg2

params_dic={"host":"localhost","database":"cms3","user":"cms3","password":""}
query="SELECT * from boundless order by level"
conn=psycopg2.connect(**params_dic)
df1=pd.read_sql_query(query,conn)
df1

pgstr=f'postgresql://cms3:@localhost:5432/cms3'
query="SELECT * from boundless order by level"
engine=create_engine(pgstr)
df2=pd.read_sql_query(query,engine)
df2