如何通过 Python Boto3 将数据加载到 Amazon Redshift? [英] How to Load Data into Amazon Redshift via Python Boto3?

查看:31
本文介绍了如何通过 Python Boto3 将数据加载到 Amazon Redshift?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Amazon Redshift 的入门指南,数据从 Amazon S3 中提取并使用 SQLWorkbench/J 加载到 Amazon Redshift 集群中.我想模拟使用 连接到集群并将示例数据加载到集群中的相同过程博托3.

In Amazon Redshift's Getting Started Guide, data is pulled from Amazon S3 and loaded into an Amazon Redshift Cluster utilizing SQLWorkbench/J. I'd like to mimic the same process of connecting to the cluster and loading sample data into the cluster utilizing Boto3.

但是在 Boto3 的文档在 Redshift 中,我找不到允许我将数据上传到 Amazon Redshift 集群的方法.

However in Boto3's documentation of Redshift, I'm unable to find a method that would allow me to upload data into Amazon Redshift cluster.

我已经能够通过以下代码使用 Boto3 与 Redshift 连接:

I've been able to connect with Redshift utilizing Boto3 with the following code:

client = boto3.client('redshift')

但我不确定哪种方法可以让我创建表或将数据上传到 Amazon Redshift,就像在 SQLWorkbenchJ 教程.

But I'm not sure what method would allow me to either create tables or upload data to Amazon Redshift the way it's done in the tutorial with SQLWorkbenchJ.

推荐答案

返回到您链接的教程中的第 4 步.看看它在哪里向您展示了如何获取集群的 URL?您必须使用 PostgreSQL 驱动程序连接到该 URL.Boto3 等 AWS 开发工具包提供对 AWS API 的访问.您需要通过 PostgreSQL API 连接到 Redshift,就像连接到 RDS 上的 PostgreSQL 数据库一样.

Go back to step 4 in that tutorial you linked. See where it shows you how to get the URL of the cluster? You have to connect to that URL with a PostgreSQL driver. The AWS SDKs such as Boto3 provide access to the AWS API. You need to connect to Redshift over a PostgreSQL API, just like you would connect to a PostgreSQL database on RDS.

这篇关于如何通过 Python Boto3 将数据加载到 Amazon Redshift?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆