Save PL/pgSQL output from PostgreSQL to a CSV file
Do you want the resulting file on the server, or on the client? Server side If you want something easy to re-use or automate, you can use Postgresql’s built in COPY command. e.g. Copy (Select * From foo) To ‘/tmp/test.csv’ With CSV DELIMITER ‘,’ HEADER; This approach runs entirely on the remote server – it … Read more