I am connected to my database (i.e. analysis) with psql, and from there I know if I do:
\o 'C/MYDIRECTORIES/test.csv'
SELECT * FROM test;
SELECT * FROM test;
I can continuously append content to this test.csv
file until I run \o
again to quit the export.
However, after some time, if I want to append new stuff into this test.csv
and if I do \o 'C/MYDIRECTORIES/test.csv'
again, test.csv
will be wiped out first. In another word, I lost my previously saved content.
I did some search online, I found this link (Using psql \o to append to a file). It offers a solution to my question. However, when I ran its suggested command:
\o | cat - >> 'C/MYDIRECTORIES/test.csv'
an error pops out like: The filename, directory name, or volume label syntax is incorrect. I double checked my path and it is correct. Can anyone help to take a look at this issue?
The problem is that this command is for UNIX, and you seem to be using Windows.
You could try and find a replacement that works on Windows, but that is notoriously difficult unless you want to write a cmd
script that does it for you.
I'll make an attempt here, but I have no Windows nearby, so it's guesswork and you'll have to debug it:
\o | CMD /D /C TYPE CON >> 'C:\\MYDIRECTORIES\\test.csv'