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

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

问题描述

在Amazon Redshift的入门指南中,使用SQLWorkbench/J从Amazon S3提取数据并将其加载到Amazon Redshift集群.我想模仿使用 Boto3 .

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的方式,该方法可以通过

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天全站免登陆