What is the issue in this case
Please run the below code, here we have removed try and except part of the code to identify where the error is happening.
param_dic = {
"host" : "localhost",
"database" : db_name,
"user" : "postgres",
"password" : db_password
}
connect = "postgresql+psycopg2://%s:%s@%s:5432/%s" % (
param_dic['user'],
param_dic['password'],
param_dic['host'],
param_dic['database']
)
engine = create_engine(connect)
print("Connection established...")
# Write data from Dataframe into Database Tables
console_df.to_sql(
'console',
con=engine,
if_exists='append',
index=False,
method='multi'
)
print("Inserted data from Console Dataframe into console table...")
Once you run this code…some error message will come, paste it here, that will help us identify the error.
Connection established…
OperationalError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py in _wrap_pool_connect(self, fn, connection)
3360 try:
→ 3361 return fn()
3362 except dialect.dbapi.Error as e:
50 frames
OperationalError: could not connect to server: Connection refused
Is the server running on host “localhost” (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host “localhost” (::1) and accepting
TCP/IP connections on port 5432?
The above exception was the direct cause of the following exception:
OperationalError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/psycopg2/init.py in connect(dsn, connection_factory, cursor_factory, **kwargs)
120
121 dsn = _ext.make_dsn(dsn, **kwargs)
→ 122 conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
123 if cursor_factory is not None:
124 conn.cursor_factory = cursor_factory
OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
Is the server running on host “localhost” (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host “localhost” (::1) and accepting
TCP/IP connections on port 5432?
(Background on this error at: https://sqlalche.me/e/14/e3q8)
This is the error I am getting
Open pgadmin and right click the area shown in the below image inside the red square
a dialog box will open and in that dialog click on connection below such dialog box will appear
Paste back the image of the dialog box here.
This is same.
This is working only in Jupyter or can i use colab ?
Same error i also got
And same window appear on postgresSql14
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.