[英]I'm getting an operational error, as described below, when trying to connect to a remote postgreSQL server through sqlalchemy
Here is the error message:这是错误消息:
OperationalError: (psycopg2.OperationalError) could not connect to server: No route to host
Is the server running on host "5432" (0.0.21.56) and accepting
TCP/IP connections on port 5432?
Here's what I've tried:这是我尝试过的:
import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
engine = create_engine('postgresql+psycopg2://tcccinxdlfzchw:86b3a71b125f827c343a88d71811fa2096744455e75abd5b5e15077bb7a910cb@5432/d2lr09vchdiec3')
Base = automap_base()
Base.prepare(engine, reflect=True)
It's from this base.prepare that I am getting the above error message, and I have tried modifying my postgresql.conf file to listen to all addresses, and my pg-hba.conf file to be host all all md5.正是从这个 base.prepare 我收到了上述错误消息,并且我尝试修改我的 postgresql.conf 文件以监听所有地址,并将我的 pg-hba.conf 文件作为所有 md5 的主机。 Then restarted the server, and I'm still getting the error.
然后重新启动服务器,我仍然收到错误消息。 Have any idea?
有什么想法吗?
I found the answer, the engine wasn't connecting simply because I wasn't providing the correct URI, which can usually be found in the details of your host site, next to port number, password, etc.我找到了答案,引擎没有连接只是因为我没有提供正确的 URI,通常可以在您的主机站点的详细信息中,在端口号、密码等旁边找到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.