简体   繁体   English

我在尝试通过 sqlalchemy 连接到远程 postgreSQL 服务器时遇到操作错误,如下所述

[英]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.

相关问题 我正在尝试使用 sqlalchemy 连接到我机器上的 SQL Express 服务器,但出现错误 - I'm trying to connect to a SQL Express Server on my machine using sqlalchemy but I'm getting an error 无法连接到 mssql 服务器,出现 SQLalchemy、操作错误和接口错误 - Unable to connect to mssql server with SQLalchemy, operational error and interface error 我开始使用 sqlalchemy。 我在处理和粘贴示例代码时遇到操作错误 - I'm getting started with sqlalchemy. I'm getting operational errors while coping and pasting the example code 我在仅访问记录中的 django 管理中遇到操作错误 - I'm getting an operational error in django administration in access records only 应用程序(Python Django,PostgreSql)已成功部署在Heroku上,但是尝试打开时出现错误 - App (Python Django, PostgreSql) is deployed successfully on Heroku, but I'm getting error when trying to open SQLAlchemy操作错误:尝试创建新的数据库行时,没有这样的表列user_id - SQLAlchemy operational error: no such table column user_id when trying to create new DB row 我试图通过pyinstaller制作.exe文件时遇到此错误-“ ModuleNotFoundError:没有名为'acrcloud_extr_tool'的模块” - I'm getting this error when I'm trying to make an .exe file through pyinstaller - “ModuleNotFoundError: No module named 'acrcloud_extr_tool'” 尝试更新表中的行时,为什么会从SQLAlchemy获得“期望的FROM表达式”? - Why am I getting “FROM expression expected” from SQLAlchemy when I'm trying to update a row in a table? 当我尝试使用代理连接到站点时,我没有收到任何数据 - I'm not getting any data when i'm trying to connect to a site with the proxy 启动Flask服务器时出现操作错误 - Getting operational error while starting flask server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM