Suraj
Suraj

Reputation: 373

How to Write/read S3 bucket file From RDS Mysql Stored Procedure

My Stored Procedure to write on S3 bucket

DELIMITER //
CREATE PROCEDURE export_product
()
BEGIN
 SET @SQLString = CONCAT('SELECT * FROM product INTO OUTFILE "https:\\s3-ap-southeast-1.amazonaws.com\bucket\download\product.csv" FIELDS TERMINATED BY ","
        LINES TERMINATED BY "\n" ');
 PREPARE test2 FROM @SQLString;
 EXECUTE test2;
END //
DELIMITER ;

Upvotes: 2

Views: 2727

Answers (1)

Deepak Singhal
Deepak Singhal

Reputation: 10874

You cannot write from MySQL RDS directly to S3.. Few Options:

  1. you need to move to MySQL Aurora RDS( Aurora being AWS service can talk to other AWS Services ).

  2. write a shell script which will run this SQL Query against your MySQL RDS. Redirect output to a flat csv file.. and then copy this csv to S3 using AWS CLI.

  3. You can also evaluate AWS Data pipeline

Upvotes: 4

Related Questions