我正在尝试通过 Python 2.7/sqlalchemy (1.2.14)/psycopg2 (2.7.6.1) 连接到 RedShift 数据库,但在配置 SSL 属性时遇到问题:
from sqlalchemy import create_engine
connection = create_engine('redshift+psycopg2://(username:password)@(server):5439/(database)?sslmode=verify-full').connect()
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) SSL error: certificate verify failed
我已经按照亚马逊的说明完成了所有步骤:
Transitioning to ACM Certificates for SSL Connections: Using Other SSL Connection Types
Install and Configure the Amazon Redshift ODBC Driver on Microsoft Windows Operating Systems
所以我现在将最新版本的 redshift-ca-bundle.crt 作为 root.crt 保存到我的 %APPDATA%\postgresql 文件夹中。我还安装了 32 位和 64 位驱动程序,并在成功验证服务器连接的两个 ODBC 管理器工具(32 位和 64 位)中配置了系统 DSN。
要在我的 Python 代码中正确配置 SSL 以便连接,我缺少什么?我知道连接需要 SSL,但不确定如何提供正确的证书。
最佳答案
我能够使用 pypyodbc 和以下连接字符串成功连接(已编辑详细信息):
connection = pypyodbc.connect('Driver={Amazon Redshift (x64)};'
'Server=<server>;'
'Database=<database>;'
'UID=<login>;'
'PWD=<password>;'
'Port=5439;'
'Trusted_Connection=True')
关于python - 连接到 RedShift 导致 SSL 错误 : certificate verify failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53293677/