I have read-only access to a database on a remote server. So, I can execute:
COPY products TO '/tmp/products.csv' DELIMITER ',';
But on that server I don't have permissions to create/save a file, so I need to do this on my local machine.
When I connect to the remote database, how can I execute a command to save the file on my local machine instead of the remote server?
Or, how can I execute a Linux command to connect to the remote database, execute a query, and save the output as a file to my local machine?
psqla script, starting withBEGIN, then doing your\copycommands, then aCOMMIT. Or usepsql -fto run a script rather than using a here-document. – Craig Ringer Dec 24 '15 at 02:36-Ainstead of-P format=unalignedand also i think you need a-P fieldsep=,– Evan Carroll Nov 08 '17 at 03:25