psql execute query and store into csv code example
Example: run postgresql dump to csv
\copy (SELECT * FROM persons) to 'C:\tmp\persons_client.csv' with csv
\copy (SELECT * FROM persons) to 'C:\tmp\persons_client.csv' with csv