How to copy csv data file to Amazon RedShift?

ciphor picture ciphor · Mar 7, 2013 · Viewed 45.3k times · Source

I'm trying to migrating some MySQL tables to Amazon Redshift, but met some problems.

The steps are simple: 1. Dump the MySQL table to a csv file 2. Upload the csv file to S3 3. Copy the data file to RedShift

Error occurs in step 3:

The SQL command is:

copy TABLE_A from 's3://ciphor/TABLE_A.csv' CREDENTIALS 'aws_access_key_id=xxxx;aws_secret_access_key=xxxx' delimiter ',' csv;

The error info:

An error occurred when executing the SQL command: copy TABLE_A from 's3://ciphor/TABLE_A.csv' CREDENTIALS 'aws_access_key_id=xxxx;aws_secret_access_key=xxxx ERROR: COPY CSV is not supported [SQL State=0A000] Execution time: 0.53s 1 statement(s) failed.

I don't know if there's any limitations on the format of the csv file, say the delimiters and quotes, I cannot find it in documents.

Any one can help?

Answer

ciphor picture ciphor · Mar 13, 2013

The problem is finally resolved by using:

copy TABLE_A from 's3://ciphor/TABLE_A.csv' CREDENTIALS 'aws_access_key_id=xxxx;aws_secret_access_key=xxxx' delimiter ',' removequotes;

More information can be found here http://docs.aws.amazon.com/redshift/latest/dg/r_COPY.html