I'm using psql to run a simple set of COPY statements contained in a file:
psql -d mydb -f 'wbf_queries.data.sql'
where wbf_queries.data.sql
contains lines:
copy <my_query> to '/home/gvkv/mydata' delimiter ',' null '';
...
but I get a permission denied error:
... ERROR: could not open file ... for writing: Permission denied
I'm connecting under my user account (gvkv) which is also a superuser in PostgreSQL. Obviously, psql is running under a different (effective) user but I don't know how to change this. Can it be done within psql or do I need some unix-fu?
UPDATE: As per araqnid's answer, here's the relevant information for anyone else who comes by:
\copy ...
Performs a frontend (client) copy. This is an operation that runs an SQL COPY command, but instead of the server reading or writing the specified file, psql reads or writes the file and routes the data between the server and the local file system. This means that file accessibility and privileges are those of the local user, not the server, and no SQL superuser privileges are required.
More here.