SQL to CSV

Quickly wrap a SQL SELECT statement in a psql COPY command, for output to a local CSV file.

  • strips line breaks, tabs, extra spaces
  • strips comments
  • wraps with \COPY