I'm trying to make a "COPY TO" querie with my node.js application. The goal is to export a database table in .csv that goes to the user downloads of my application. I first tried to write the database table in an existing file with the following querie :
async function exportDatabase(req, res){
return db.any("COPY tag_7z8eq73 to 'C:\Users\New-rFid-Concept\Documents\BioTech_mathis\tag_7z8eq73.csv' delimiters '|' CSV HEADER")
.then(rows => {
res.json(rows)
})
.catch(error => {
console.log(error)
});
}
But the following error is returning : "A relative path is not allowed to use COPY to a file" which means that I have no permission.
From what I understand I have to write to STDOUT but when I send this querie nothing happens in my debug console in VScode or anything else.
I tried :
"COPY tag_7z8eq73 TO STDOUT csv header"
"COPY tag_7z8eq73 TO STDOUT"
"\copy tag_7z8eq73 TO STDOUT"
and others..
Do you know what would be the query that would allow me to create a .csv file with my node.js application?