简体   繁体   English

使用 Golang API 将 Amazon RDS 中的表导出到 csv 文件中

[英]Exporting table from Amazon RDS into a csv file using Golang API

I am looking for some way to directly export the SQL query results to a CSV file from AWS lambda.我正在寻找某种方法将 SQL 查询结果从 AWS lambda 直接导出到 CSV 文件。 I have found this similar question - Exporting table from Amazon RDS into a csv file .我发现了这个类似的问题 - Exporting table from Amazon RDS into a csv file But it will not work with the AWS Golang API.但它不适用于 AWS Golang API。

Actually, I want to schedule a lambda function which will daily query some of the views/tables from RDS(SQL Server) and put it to the S3 bucket in CSV format.实际上,我想安排一个 lambda 函数,它将每天从 RDS(SQL Server) 查询一些视图/表,并将其以 CSV 格式放入 S3 存储桶。 So, I want to directly download the query results in the CSV form in the lambda and then upload it to S3.所以,我想直接在lambda中以CSV形式下载查询结果,然后上传到S3。

I have also found data pipeline service of AWS to copy RDS data to S3 directly, but I am not sure if I can make use of it here.我还找到了AWS的数据管道服务,可以直接将RDS数据复制到S3,但我不确定我是否可以在这里使用它。

It would be helpful if anyone can suggest me the right process to do it and references to implement it.如果有人可以向我建议正确的流程以及实施它的参考资料,那将会很有帮助。

You can transfer files between a DB instance running Amazon RDS for SQL Server and an Amazon S3 bucket.您可以在运行 Amazon RDS for SQL Server 的数据库实例和 Amazon S3 存储桶之间传输文件。 By doing this, you can use Amazon S3 with SQL Server features such as BULK INSERT.通过这样做,您可以将 Amazon S3 与 SQL Server 功能(例如 BULK INSERT)结合使用。 For example, you can download .csv, .xml, .txt, and other files from Amazon S3 to the DB instance host and import the data from D:\\S3\\into the database.例如,您可以将 .csv、.xml、.txt 和其他文件从 Amazon S3 下载到数据库实例主机,并将数据从 D:\\S3\\导入数据库。 All files are stored in D:\\S3\\ on the DB instance所有文件都存储在数据库实例上的 D:\\S3\\

Reeference:参考:

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/User.SQLServer.Options.S3-integration.html https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/User.SQLServer.Options.S3-integration.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM