连接到redshift时出错:“服务器证书与主机名不匹配”

时间:2021-04-25 23:06:33

After trying to run a query on redshift, I get the following error message:

在尝试对红移进行查询后,我得到以下错误消息:

OperationalError: (psycopg2.OperationalError) server certificate for "" does not match host name "".

OperationalError:(psycopg2.OperationalError)“”的服务器证书与主机名“不匹配”。

I already installed the sqlalchemy-redshift package, as well as the Psycopg2 package. My code:

我已经安装了sqlalchemy-redshift包以及Psycopg2包。我的代码:

from sqlalchemy import create_engine

def run_query(query, connection_string):

 red_engine = create_engine(connection_string)
 data_set = pd.read_sql_query(query, red_engine)

 return data_set

The exact same code does work on another computer, so we are sure that the login name, password and queries are correct, and the problem is specific to my computer. Any suggestions?

同样的代码在另一台计算机上也能工作,所以我们确信登录名、密码和查询都是正确的,而且问题是我的计算机特有的。有什么建议吗?

1 个解决方案

#1


5  

This worked for me in the end: we added a preffered sslmode to our code, as follows:

这对我来说很有效:我们在代码中添加了一个preffered sslmode,如下所示:

create_engine(connection_string, connect_args={'sslmode': 'prefer'})

create_engine(connection_string connect_args = { ' sslmode ':'喜欢' })

#1


5  

This worked for me in the end: we added a preffered sslmode to our code, as follows:

这对我来说很有效:我们在代码中添加了一个preffered sslmode,如下所示:

create_engine(connection_string, connect_args={'sslmode': 'prefer'})

create_engine(connection_string connect_args = { ' sslmode ':'喜欢' })