Today we learned that Posgres has the ability to copy data from a query straight into a CSV format. You can output the CSV data directly to a file or STDOUT in your terminal.
COPY (SELECT * FROM posts) TO STDOUT WITH csv HEADER;
You can also do this in reverse to add data to Postgres using COPY posts FROM STDIN WITH csv HEADER