Reputation: 41
ERROR: could not open file "C:\Users\lenovo\Downloads\Owners.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
I am trying to import a csv file into postgresql. But this error pops up. I search everywhere. But i Couldn't get the answer of it PLEASE HELP ME.
THANKS IN ADVANCE!!
Upvotes: 1
Views: 570
Reputation: 44240
COPY mytable FROM /path/thefile.csv WITH CSV,HEADER;
is executed by the DBMS server, the .csv-file is read by the server. The server (typically) runs as user postgres, which cannot access arbitrary users's files. (Also: the client and server don't have to be running on the same machine) There are two possible solutions to this:
/tmp/
, or somewhere under its home-directory.\copy mytable(col1,col2,...) FROM '/path/file.csv'...
(slightly different syntax)Upvotes: 2