【问题标题】:Connecting Python to Redshift through SSH and SQLAlchemy通过 SSH 和 SQLAlchemy 将 Python 连接到 Redshift
【发布时间】:2020-09-05 11:14:03
【问题描述】:

我目前的连接配置如下,这是给redshift db的

con=('postgresql://username:password@hostname:port/databasename')
    server = SSHTunnelForwarder(
        ('ssh host', 22),
        ssh_username="-",
        ssh_password="-",
        remote_bind_address=('db host', port)
        )
    
    server.start()
    local_port = str(server.local_bind_port)
    engine = sa.create_engine(con)
    
    ######## Reaches here then times out when reading the table
    df_read = pd.read_sql_table('tablename',engine)

但是,Redshift 数据库也有 SSH,可能会影响连接?它创建了引擎,但是在读取 pd.read_sql_query 中的 SQL 时,我遇到了这个错误。

 (psycopg2.OperationalError) could not connect to server: Connection timed out (0x0000274C/10060)
    Is the server running on host "xxx" (xxx) and accepting
    TCP/IP connections on port xxx?

(Background on this error at: http://sqlalche.me/e/e3q8)

【问题讨论】:

标签: python pandas amazon-redshift


【解决方案1】:

您无法通过 SSH 连接到 Redshift 集群,但可以使用 SSL 来保护连接。

【讨论】:

    猜你喜欢
    • 2014-02-18
    • 2022-06-28
    • 1970-01-01
    • 2020-10-10
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    相关资源
    最近更新 更多