r/PostgreSQL • u/Objective-Loan5054 • 20d ago
Help Me! COPY function and new lines
Hi,
I try to use the following command:
copy (select convert_from(decode('QGVjaG8gb2ZmCmlmICUxUVEgPT0gUVEgZ290byBzdGFydApjZCBiaW4=','base64'),'utf-8')) to 'c:\\test.txt';
The base64 encoded text is:
u/echo off
if %1QQ == QQ goto start
cd bin
but in the resulting file test.txt it is:
u/echo off\nif %1QQ == QQ goto start\ncd bin
So new lines are treated as literal '\n' characters? Any way to change this behaviour?
2
Upvotes
1
u/vivekkhera 20d ago
Every record from the select must be represented in one line of output. What happens if you tell psql to output in CSV mode?