0

I am trying to import data from a CSV file into PostgreSQL using pgAdmin. However, I am getting an error message when attempting to perform a COPY command.

ERROR: could not open file "/Users/brandoncruz/Desktop/Test File.csv" for reading: Permission denied HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy. SQL state: 42501

Below is the code I have attempted to use for the import.

CREATE TABLE roles(
role_id serial PRIMARY KEY,
role_name VARCHAR (255)
);       

COPY roles FROM '/Users/brandoncruz/Desktop/Test File.csv'  DELIMITER ',' CSV HEADER;
Brandon Cruz
  • 19
  • 1
  • 3
  • 1
    Possible duplicate of [I am trying to copy a file, but getting error message](https://stackoverflow.com/questions/54031813/i-am-trying-to-copy-a-file-but-getting-error-message) – JGH Nov 27 '19 at 19:41

2 Answers2

0

It looks about your permissions. You can change permissions of 'Test File.csv'. I mean Postgres user cannot read your file. After change permissions it must be copied successfully.

berkancetin
  • 315
  • 1
  • 3
  • 18
0

You might need to check following path if you are using pgAdmin: pgAdmin > File > Preferences Paths > Binary Paths For postgreSQL binary path, you should find the location of PostgreSQL from your mac and save that: i.e. C:\Program Files\PostgreSQL\12\bin (Windows) For mac, check under Applications, Program Files, that depends and changes from Mac to Mac.