I am trying to import s3 file(CSV file) to Postgre sql rds instance. I am running s3 import queries from rds instance as per AWS docs but i am getting below error
ERROR: syntax error at or near ":" LINE 5: :'s3_uri', ^ SQL state: 42601 Character: 76
Query i used for downloading s3 file is below:
SELECT aws_s3.table_import_from_s3( 't1', '', '(format csv)', :'s3_uri', );
Running query as per AWS doc: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Procedural.Importing.html#USER_PostgreSQL.S3Import.Overview
SELECT aws_s3.table_import_from_s3( 't1', '', '(format csv)', :'s3_uri', );
:'
is not a valid syntax. :'s3_uri'
, including the leading colon, need to be replaced with a s3 URI. When you are done, there should be no literal colon there outside the quotes.
I had the same error. Solved it with these steps:
CREATE EXTENSION aws_s3 CASCADE;
SELECT aws_commons.create_aws_credentials('access_key','secret_key') as credentials;
SELECT aws_commons.create_s3_uri('bucket_name', 'file_name.csv') AS s3_uri_1 \gset
SELECT aws_s3.table_import_from_s3('table_name','','(format csv)',:'s3_uri_1');
References:
Try add \n before:
SELECT aws_s3.table_import_from_s3( 't1', '', '(format csv)',
:'s3_uri', );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.