亚马逊S3中的CSV文件到亚马逊SQL

亚马逊S3中的CSV文件到亚马逊SQL

本文介绍了亚马逊S3中的CSV文件到亚马逊SQL Server rds的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有示例可以找到如何将数据从Amazon S3内的CSV文件复制到Microsoft SQL Server Amazon RDS中?

Is there any sample where I can find how to copy data from a CSV file inside Amazon S3 into a Microsoft SQL Server Amazon RDS ?

在文档中仅提到了将数据从本地数据库导入RDS.

In the documentation its only mentioned about importing data from a local db into RDS.

推荐答案

似乎他们设置了与S3的Sql Server RDS集成.我发现这篇AWS文档文章详细说明.

It looks like they setup Sql Server RDS integration with S3. I found this aws docs article which explains it in good detail.

设置正确的凭据后,它们似乎会添加特定的存储过程以下载(并上载/删除)到D:\S3目录.我还没有亲自完成此操作,但是我想分享一下,因为在另一篇文章的评论中提到不支持BULK INSERT.但这将为BULK INSERT使用s3中的文件提供一种方式.

After you've setup the proper credentials, it appears they added specific stored procedures to download (and upload/delete) to a D:\S3 directory. I haven't personally done this, but I thought I would share since the comment on the other post mentions that BULK INSERT isn't supported. But this would provide a way for BULK INSERT to work using a file from s3.

将文件复制到RDS实例:

Copy the file to the RDS instance:

exec msdb.dbo.rds_download_from_s3
        @s3_arn_of_file='arn:aws:s3:::bucket_name/bulk_data.csv',
        @rds_file_path='D:\S3\seed_data\data.csv',
        @overwrite_file=1;

然后运行BULK INSERT:

BULK INSERT MyData
FROM 'D:\S3\seed_data\data.csv'
WITH
(
    FIRSTROW = 2,
    FIELDTERMINATOR = ',',
    ROWTERMINATOR = '\n'
)

这篇关于亚马逊S3中的CSV文件到亚马逊SQL Server rds的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 03:14