I am trying to connect to a database in Postgres to insert data into my tables.
From Jupyter Notebook. Iam using these commands
connect to the database
#url = postgresql+psycopg2://postgres@localhost:5432/citibike’
from sqlalchemy import create_engine
engine = create_engine('postgresql://localhost/citibike')
con = engine.connect()
df_date.to_sql('date_dim', con, if_exists='append',index=False,chunksize=10000)
stations.to_sql('stations', con, if_exists='append',index=False,chunksize=10000)
trip_demo.to_sql('trip_demo', con, if_exists='append',index=False,chunksize=10000)
df_weather.to_sql('weather', con, if_exists='append',index=False,chunksize=10000)
rides.to_sql('rides', con, if_exists='append',index=False,chunksize=10000)
con.close()`
but when I try to run the code I am getting this error
OperationalError: (psycopg2.OperationalError) connection to server at “localhost” (::1), port 5432 failed: FATAL: role “rkb18” does not exist
I have checked my login details and all the details for host, database, username, port etc are correct.
rkb18 is my user name in the Windows hierarchy on my laptop but I am not sure how this is involved with what I am trying to do here.
I am using postbird as my interface to postgres
any help/advice would be appreciated.
Ray B is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.