I'm creating an export to csv that's a rather long query, as such, I placed the \copy command in a new file. The problem is that the newlines seem to break my command, is there a way I'm able to execute this command with line breaks?
For example:
\copy (select
field1
, field2
FROM table
) to '/tmp/out.csv' csv;
I'm currently running that command from a sql file as such:
psql -f tocsv.sql
I don't think it matters that I'm running it from a file. Is there a way to execute the copy command with the line breaks in my query? I'd like to keep them there for legibility.