python - 通过 SSH 和 SQLAlchemy 将 Python 连接到 Redshift

标签 python pandas amazon-redshift

我当前的连接配置如下,这是针对 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)

最佳答案

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

关于python - 通过 SSH 和 SQLAlchemy 将 Python 连接到 Redshift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61890203/

相关文章:

r - JDBC 创建表并在 amazon redshift 中插入时出错

python - 大数的质因数

python - 大文件读取问题

python - 在一列上对数据框进行分组,并从一列中获取最大值,并从另一列中获取相应的值

python - 找不到我的数据集的异常值(更具体地说是 IQR)

postgresql - 基准 Amazon Redshift JSON_EXTRACT_PATH_TEXT

amazon-web-services - 亚马逊 Redshift 中的并发查询性能

python - Emacs 组织模式 : Executing simple python code

python - 每次为 Pandas DataFrame 获取相同的哈希值

python - 有没有一种简单的方法可以将 PyCharm 和 WinPython 的整个安装放在 USB 内存棒上?