2013-07-19 60 views
1

我想将一个文件放到我的Postgresql系统中(具体为RedShift)。我发现了一个允许导入gzip文件的副本的争论。但是,我试图在我的系统中包含的数据提供者仅生成.zip中的数据。任何内置的postgres命令用于打开.zip?如何将ZIpped文件导入Postgres表

回答

1

可你只是像做

unzip -c myfile.zip | gzip myfile.gz

很容易,如果你有足够的文件实现自动化。

+1

文件不被本地存储和数据库是不是本地的。 –

+0

Ug。那么这让我很难受,因为我不认为amzn有任何选择。你可以在存储文件的服务器上访问exec psql并以这种方式连接吗?否则,可能需要通过中间人服务器发送文件。 –

0

unzip -c /path/to/.zip | psql -U user

'用户' 必须拥有超级用户权限,否则你会得到一个

ERROR: must be superuser to COPY to or from a file 

要了解更多有关这看

https://www.postgresql.org/docs/8.0/static/backup.html

基本上这个命令用于

这是对作品的格式为:处理大型数据库

0

这仅会从S3加载红移时将数据复制到红移表描述here工作,但实际上你可以只包括一个“压缩”标志,我如果我的S3存储桶包含一个压缩.csv。

copy <table> from 's3://mybucket/<foldername> '<aws-auth-args>' delimiter ',' gzip; 
0

从内Postgres的:

COPY table_name FROM PROGRAM 'unzip -p input.csv.zip' DELIMITER ','; 

从手册页unzip -p

-p  extract files to pipe (stdout). Nothing but the file data is sent to stdout, and the files are always extracted in binary 
     format, just as they are stored (no conversions). 
相关问题