Blog Archive for August 4, 2015

Postgres Table to CSV

August 4, 2015

I just found a simple way to create CSV files from database tables in postgres:

mybandsite=# copy (select * from news_newsitem where site_id = 2) to '/tmp/news.csv' DELIMITER ',' CSV HEADER
COPY 34

This will create a file news.csv which will contain all the rows returned by the specified query. …