1

Currently I can almost get a CSV from psql by simply running

psql -A -t -F'\t' -c "SELECT ...;" > myfile.csv

However it returns the number of rows at the end of the file. I can fix his with head -n -1

psql -A -t -F'\t' | head -n -1 | -c "SELECT ...;"

But with very large files seems like overkill. Is here a flag in psql where I can turn off number of records returned?

a_horse_with_no_name
  • 440,273
  • 77
  • 685
  • 758
ForeverConfused
  • 1,247
  • 3
  • 17
  • 34

1 Answers1

3

There is a number of common ways to get a CSV from PostrgeSQL (see e.g. this question). However not all of these ways are appropriate when working with Redshift, partly because Amazon Redshift is based on Postgres 8.0.2.

One can try to use --pset="footer=off" option to prevent psql from outputting the number of rows. Also, please consult 8.0.26 psql documentation.

Stanislav Kralin
  • 10,115
  • 4
  • 30
  • 52