【问题标题】:I want to load data into an Amazon Redshift Cluster using python boto3 script我想使用 python boto3 脚本将数据加载到 Amazon Redshift 集群中
【发布时间】:2019-07-14 22:12:32
【问题描述】:

我想使用 boto3 Python 脚本将数据加载到 Amazon Redshift 集群中。

我想使用 boto3 python 创建一个脚本来执行以下操作:

  1. 创建集群
  2. 将数据加载到集群中
  3. 创建集群性能报告

我在 boto3 中看到没有可用于将数据加载到集群中的方法。可能来自平面文件或 S3。

如何使用 boto3 或任何其他 python 包将数据加载到集群中?

【问题讨论】:

    标签: python amazon-web-services amazon-redshift boto3


    【解决方案1】:

    1.创建 Amazon Redshift 集群

    调用create_cluster() 命令。

    2。将数据加载到集群中

    Amazon Redshift 像普通的 PostgreSQL v8.0.2 数据库一样运行。要在数据库本身上运行命令(包括COPY 命令),您应该建立到数据库的 JDBC/ODBC 连接。

    见:Connecting to an Amazon Redshift Cluster Using SQL Client Tools - Amazon Redshift

    一种常用的方法是使用psycopg2

    conn = psycopg2.connect(...)
    cur = conn.cursor()
    cur.execute("COPY...")
    conn.commit()
    

    见:Copying data from S3 to AWS redshift using python and psycopg2

    3.创建集群性能报告

    绩效报告有两种信息来源:

    见:Monitoring Amazon Redshift Cluster Performance - Amazon Redshift

    【讨论】:

    • 优秀。很好的答案,非常感谢。再次感谢。
    猜你喜欢
    • 2016-05-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 2015-07-24
    • 2018-11-18
    • 1970-01-01
    相关资源
    最近更新 更多