0

When i run the below code to import data from csv file stored in azure storage account i get following error: syntax error at or near "CREDENTIALS"

    COPY ccsm.vital_signs FROM
    'https://abc.blob.core.windows.net/dta/abc.csv'
    CREDENTIALS ''
    DELIMITER '|'
    CSV HEADER;
Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
Sachin
  • 35
  • 1
  • 1
  • 6

1 Answers1

0

I found CREDENTIALS is only used in Amazon Redshift(based on but different from psql), which is not valid in psql according to its document.

Don't find any similar operation supported by Azure psql either.

So I recommend you to download the file first, then import it.

Note that we don't have superuser privilege to use COPY method in Azure psql, see this thread. So we have to use local psql tool with \copy method.

Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
  • Ok Thank you Jerry. The files are very large it would be time consuming. But I was wandering is there any other alternative available like to load data into azure sql db and then import it from there to azure psql? – Sachin May 31 '18 at 12:18
  • And also \copy does not works in pgAdmin4 and dbforge studioa express for psql. – Sachin May 31 '18 at 12:30
  • @Sachin Sorry about the ambiguous description. `local psql tool` means client command line tool, included in [psql installation](https://www.postgresql.org/download/). About the alternative, I will reply to you if I get any progress. – Jerry Liu Jun 01 '18 at 04:43
  • We came across the same issue, we wanted the speed of Bulk Copy. We opted to use npgsql's .NET provider and used the NpgsqlBinaryImporter. There is setup involved to identify the structures of the files, but it works for us. More info here https://www.npgsql.org/doc/copy.html – Ed Mendez Mar 30 '19 at 02:01