Python 无法使用pg8000连接到AWS RDS Postgres,但适用于psycopg2
朋友们 我正在尝试从运行在EC2机器上的python脚本连接到AWS RDS中的Postgres实例。它与psycopg2/sqlalchemy配合得很好Python 无法使用pg8000连接到AWS RDS Postgres,但适用于psycopg2,python,postgresql,amazon-rds,psycopg2,pg8000,Python,Postgresql,Amazon Rds,Psycopg2,Pg8000,朋友们 我正在尝试从运行在EC2机器上的python脚本连接到AWS RDS中的Postgres实例。它与psycopg2/sqlalchemy配合得很好 from sqlalchemy import create_engine import psycopg2 db_string = 'postgresql+psycopg2://{user}:{password}@{host}:5432/{database}'.format( user=DB_USER, pa
from sqlalchemy import create_engine
import psycopg2
db_string = 'postgresql+psycopg2://{user}:{password}@{host}:5432/{database}'.format(
user=DB_USER,
password=DB_PASS,
host=DB_HOST,
database=DB_NAME)
engine = create_engine(db_string, echo=True)
conn = engine.connect()
from sqlalchemy import create_engine
import pg8000
db_string = 'postgresql+pg8000://{user}:{password}@{host}:5432/{database}'.format(
user=DB_USER,
password=DB_PASS,
host=DB_HOST,
database=DB_NAME)
engine = create_engine(db_string, echo=True)
conn = engine.connect()
但当我使用pg8000/sqlalchemy作为
from sqlalchemy import create_engine
import psycopg2
db_string = 'postgresql+psycopg2://{user}:{password}@{host}:5432/{database}'.format(
user=DB_USER,
password=DB_PASS,
host=DB_HOST,
database=DB_NAME)
engine = create_engine(db_string, echo=True)
conn = engine.connect()
from sqlalchemy import create_engine
import pg8000
db_string = 'postgresql+pg8000://{user}:{password}@{host}:5432/{database}'.format(
user=DB_USER,
password=DB_PASS,
host=DB_HOST,
database=DB_NAME)
engine = create_engine(db_string, echo=True)
conn = engine.connect()
错误信息是
InterfaceError: (pg8000.exceptions.InterfaceError) {'S': 'FATAL', 'V': 'FATAL', 'C': '28000', 'M': 'no pg_hba.conf entry for host "*.*.*.*", user "*", database "*", SSL off', 'F': 'auth.c', 'L': '513', 'R': 'ClientAuthentication'}
(Background on this error at: http://sqlalche.me/e/14/rvf5)
我还尝试设置connect\u args={'ssl\u context':True}
,但连接仍然失败。有人有什么想法吗?我正在使用python v3.6、sqlalchemy v1.4.15和pg8000 v1.19.4。
谢谢。我的错。ssl_上下文适用于pg8000。谢谢。当您添加
ssl\u context:True
时,我假设错误消息会更改?这是你需要注意的错误。