简体   繁体   English

如何通过 SSH 隧道从 Excel VBA 连接到 Amazon RDS 上的 PostgreSQL?

[英]How to connect to PostgreSQL on Amazon RDS from Excel VBA via SSH tunnel?

Here's the VBA code that I'm using to connect to a local instance of PostgreSQL:这是我用来连接到 PostgreSQL 的本地实例的 VBA 代码:

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.Open "DSN=PostgreSQL-Local"

This is what the ODBC data source setup looks like:这是 ODBC 数据源设置的样子:

Now, I want to connect to the prod version in Amazon RDS, which is not publicly available.现在,我想连接到 Amazon RDS 中的产品版本,它不公开可用。 I've set up the SSH tunnel (via an EC2 instance) and I'm able to connect to the database after configuring DBeaver's SSH tunnel tab.我已经设置了 SSH 隧道(通过 EC2 实例),并且在配置 DBeaver 的 SSH 隧道选项卡后我能够连接到数据库。

So, I know that the SSH tunnel works perfectly well.所以,我知道 SSH 隧道运行良好。

I tried:我试过了:

  • finding configuration options in the ODBC data sources在 ODBC 数据源中查找配置选项
  • searching the inte.net for connection strings在互联网上搜索连接字符串

However, I'm stuck with figuring out how to do it using VBA's ADODB connection.但是,我一直在弄清楚如何使用 VBA 的ADODB连接来完成它。

The opensource psqlODBC driver doesn't come with integrated ssh tunneling.开源 psqlODBC 驱动程序没有集成 ssh 隧道。

DevArt sells a driver which does, or you can install your own tunneling software and set up the tunnel yourself. DevArt 出售一个驱动程序,或者您可以安装自己的隧道软件并自己设置隧道。 In the latter case, you would need to then point your ODBC driver at localhost:5433 (or whatever port you chose to use locally--I gave that as an example as 5432 seems to already be in use locally)在后一种情况下,您需要将 ODBC 驱动程序指向 localhost:5433(或您选择在本地使用的任何端口——我举这个例子,因为 5432 似乎已经在本地使用)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM