Export text exactly from psql
psql
will automatically add headers to output and wrap long lines of text. To get the value without this noise switch to tuples only mode and unaligned format.
\t on
\pset format unaligned
This can be combined with a previous TIL by joshbranchaud to export the query output to a file.
select body from posts where id=123 \g post123.txt
Tweet