>psql dbname
psql>f ','
psql>a
psql>o '/tmp/output.csv'
psql>SELECT * from users;
psql>q
----------------------------------
COPY (SELECT * from users) To '/tmp/output.csv' With CSV;
-----------------------------------------
psql -d dbname -t -A -F"," -c "select * from users" > output.csv