如何从S3导入数据文件到Postgresql RDS [英] how to import data files from s3 to postgresql rds

查看:305
本文介绍了如何从S3导入数据文件到Postgresql RDS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是AWS和Postgresql的新手。

I am very new to AWS, and Postgresql.


  1. 我已经创建了一个Postgresql数据库(在was上使用rds)

  2. 我已将多个文档上载到多个s3存储桶

  3. 我正在运行EC2(Amazon Linux 64位)

我尝试使用数据管道,但是Postgres似乎没有可用的(模板)。我无法弄清楚如何连接到RDS实例以及如何从postgres导入/导出数据。

I tried to use a data pipeline, but nothing seems to be available (template) for Postgres. I can't figure out how to connect to my RDS instance and import/export data from postgres.

我假设我可以使用EC2从我的S3存储桶中抓取,导入Postgres代替没有可用的数据管道模板。

I assumed that I could use EC2 to grab from my S3 bucket and import into Postgres in lieu of no data pipeline template being available. If it is possible I have no idea how.. Please advise if possible..

推荐答案

我希望AWS在RDS中扩展COPY命令就像在Redshift中所做的那样。但是到目前为止,他们还没有,我们必须自己做。

I wish AWS extends COPY command in RDS Postgresql as they did in Redshift. But for now they haven't and we have to do it by ourselves.


  1. 安装 awscli 在EC2盒上(可能默认情况下已安装)

  2. 使用凭据配置 awscli

  3. 使用 aws s3 sync aws s3 cp 命令从s3下载到本地目录

  4. 使用psql命令将文件 \COPY 放入RDS(需要 \ 从客户端目录复制)

  1. Install awscli on your EC2 box (it might have been installed by default)
  2. Configure your awscli with credentials
  3. Use aws s3 sync or aws s3 cp commmands to download from s3 to your local directory
  4. Use psql command to \COPY the files into your RDS (requires \ to copy from client directory)

示例:

aws s3 cp s3://bucket/file.csv /mydirectory/file.csv
psql -h your_rds.amazonaws.com -U username -d dbname -c '\COPY table FROM ''file.csv'' CSV HEADER'

这篇关于如何从S3导入数据文件到Postgresql RDS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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