I want to connect to a postgres database server through google colab but when I connect with this code I get the error below.
Please I need help
from sqlalchemy import create_engine
import psycopg2
host= "xxx.xxx.x.xxx:5432"
user= "user"
password= "psw"
nombre_db= "name"
url= "postgresql://{user}:{password}@{host}/{nombre_db}"
engine =create_engine(url)
conn = engine.connect()
conn
ERROR:
OperationalError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py in _wrap_pool_connect(self, fn, connection)
3210 try:
-> 3211 return fn()
3212 except dialect.dbapi.Error as e:
39 frames
OperationalError: could not translate host name "{host}" to address: Name or service not known
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)
128
129 dsn = _ext.make_dsn(dsn, **kwargs)
--> 130 conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
131 if cursor_factory is not None:
132 conn.cursor_factory = cursor_factory
OperationalError: (psycopg2.OperationalError) could not translate host name "{host}" to address: Name or service not known
(Background on this error at: http://sqlalche.me/e/14/e3q8)