【发布时间】:2015-08-31 20:02:46
【问题描述】:
我正在使用最新版本的 IntelliJ,并且刚刚在 Amazon Redshift 中创建了一个集群。如何将 IntelliJ 连接到 Redshift,以便我可以从我最喜欢的 IDE 中查询它?
【问题讨论】:
标签: amazon-web-services intellij-idea amazon-redshift
我正在使用最新版本的 IntelliJ,并且刚刚在 Amazon Redshift 中创建了一个集群。如何将 IntelliJ 连接到 Redshift,以便我可以从我最喜欢的 IDE 中查询它?
【问题讨论】:
标签: amazon-web-services intellij-idea amazon-redshift
View |Tool Windows | Database +)并选择“数据库驱动”:取消选中“JDBC 驱动程序”,并添加一个 jdbc 驱动程序,从下拉列表中选择一个类并选择一个 PostgreSQL 方言:
6.添加一个新连接,并将此数据源用于您的连接:(+ | Data Source | RedShift)。
7.设置网址模板:
jdbc:redshift://[{host::localhost}[:{port::5439}]][/{database::postgres}?][\?<&,user={user:param},password={password:param},{:identifier}={:param}>]
jdbc:redshift://\[{host:ipv6:\:\:1}\][:{port::5439}][/{database::postgres}?][\?<&,user={user:param},password={password:param},{:identifier}={:param}>]
jdbc:redshift:{database::postgres}[\?<&,user={user:param},password={password:param},{:identifier}={:param}>]【讨论】:
您可以使用 Amazon 提供的 JDBC 驱动程序将 IntelliJ 连接到 Redshift。在 Redshift 控制台中,转到“连接客户端”以获取驱动程序。
然后,在 IntelliJ 数据源窗口中,将 JAR 添加为驱动程序文件,并使用以下设置:
常见的陷阱:
如需更详细的指南,请参阅此博文:Connecting IntelliJ to Redshift
注意:IntelliJ 中还没有原生的 Redshift 支持。 IntelliJ Issue DBE-1459
【讨论】:
2020 年更新:PyCharm(可能还有所有其他 JetBrains IDE)现在支持通过 IAM AWS 凭证连接到 Redshift无需手动安装驱动程序。
以下是详细的设置说明:
向您的 AWS 用户授予 redshift:GetClusterCredentials 权限。创建并附加新策略 (docs) 或使用现有策略,例如 AmazonRedshiftFullAccess(不推荐:过于宽松)。
为您的用户 (docs) 创建一个 AWS 访问密钥(访问密钥 ID + 秘密访问密钥对)。
创建一个文本配置文件~/.aws/credentials(无扩展名),内容如下(docs):
[default] # arbitrary profile name, will be used later
region = <your region>
aws_access_key_id = <your access key id> # created on the previous step
aws_secret_access_key = <your secret access key>
IAM cluster/region(就在连接设置窗口的“常规”选项卡下方)。AWS Profile
{your AWS login}
default 或您在凭证文件中使用的那个。
AccessKeyID/SecretAccessKey 连接设置提供凭据,但它对我不起作用(如果 Profile 字段为空,则会出现 NullPointerException)。{your database},选择一个现有的,以免遇到来自驱动程序的非描述性错误。{your region}
{cluster name},从 Redshift AWS console 获取。AutoCreate = true(文字小写true作为设置值)。这将使用您的 AWS 登录名自动创建一个新的数据库用户。【讨论】: