I want to import a large csv file without creating table before for that csv file into postgresql. While searching on stackoverflow, one of the user suggested the following code:
from sqlalchemy import create_engine
engine = create_engine('postgresql://username:password@localhost:5432/mydatabase')
df.to_sql('table_name', engine)
Based on this I wrote the following code based on the information for my postgresql which has username = "postgres" and password = "Katherine@412":
from sqlalchemy import create_engine
engine = create_engine('postgresql://[postgres]:Katherine@412@postgres:5432/covid_deaths.csv')
df.to_sql('covid_deaths_owid', engine)
However it is giving me the following error:
OperationalError: (psycopg2.OperationalError) could not translate host name "412@postgres" to address: Unknown server error
Can someone tell me what I am doing wrong?