1
votes

I am looking for some way to directly export the SQL query results to a CSV file from AWS lambda. I have found this similar question - Exporting table from Amazon RDS into a csv file. But it will not work with the 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. So, I want to directly download the query results in the CSV form in the lambda and then upload it to 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.

It would be helpful if anyone can suggest me the right process to do it and references to implement it.

1
Are you lloking for this query results to a CSV file in the local machine or I want to schedule a lambda function (I assume you refer to AWS lambda). Running code in cloud and in local machine are two different things.Dmitry Harnitski
@DmitryHarnitski Sorry for the confusion. I want to schedule a lambda function.Rahul Satal

1 Answers

1
votes

You can transfer files between a DB instance running Amazon RDS for SQL Server and an Amazon S3 bucket. By doing this, you can use Amazon S3 with SQL Server features such as 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. All files are stored in D:\S3\ on the DB instance

Reeference:

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