使用Python redshift_connector连接AWS Redshift Serverless超时问题求助
Redshift Serverless本地Python连接问题
我在AWS上创建了Redshift Serverless数据库,已有数据且可通过Query Editor v2正常查询,但使用redshift_connector库通过本地Python代码连接时遇到问题(文档显示该库支持Serverless版本)。
连接代码
conn = redshift_connector.connect( host='hostid', database='dev', port=5439, user='my user', password='my pw' )
报错信息
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
已完成的排查步骤
- 端点格式验证:使用的host是Redshift端点字段值,已去除末尾的
:5439/dev,格式为<name>.111111111111.<aws-region>.redshift-serverless.amazonaws.com;修改该值会触发其他错误,确认host、数据库名及端口均正确 - 已将Redshift Serverless命名空间设置为公开可访问,但问题仍未解决
疑问点
- 除了设置命名空间公开访问,还需要配置哪些安全设置才能允许本地Python访问数据库?
- 无法确认Redshift数据库的正确用户名/密码:尝试过AWS账号的用户名/密码组合、能正常与S3交互的AWS访问密钥,均无效。Query Editor v2中访问数据的账号凭证在哪里获取?
尝试过的另一种连接方式(使用AWS密钥)
conn = redshift_connector.connect( host='hostid', database='dev', port=5439, access_key_id=AWS_ACCESS_KEY_ID, secret_access_key=AWS_SECRET_ACCESS_KEY )
内容的提问来源于stack exchange,提问作者KajZ
相关产品推荐
相关产品推荐

