run COPY as user other than postgres

From: Kirk Wythers <wythe001(at)umn(dot)edu>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: run COPY as user other than postgres
Date: 2013-04-23 20:11:21
Message-ID: A58A7CEC-6F60-4ADB-AC88-655DCBC10123@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I would like to run the COPY command as a user other than "postgres". I find it a bit of a pain (or at least requiring an extra step or two) to have the postgres user own the files that I am creating with COPY TO. Here is a simple example where the location '/some/path/to/file/file.csv' is owned by another user and it would be very spiffy if I could run the COPY TO as that user. Any ideas?

COPY (
SELECT * FROM
some_table
WHERE
2012 = EXTRACT (YEAR FROM some_column) --AND value IS NOT NULL
)
TO '/some/path/to/file/file.csv' WITH CSV HEADER;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ryan Kelly 2013-04-23 20:20:27 Re: run COPY as user other than postgres
Previous Message François Beausoleil 2013-04-23 19:14:47 Re: pg_stop_backup running for 2h10m?