相对路径不允许使用复制到文件
我制作了一个函数,以便当我单击一个按钮时,它将“副本”到服务器的“ Querie”。目标是在.CSV中导出一个表数据库,该数据库将用于我的应用程序的用户下载。 我首先尝试将数据库表在现有文件中写入以下查询:
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)
});
}
的数据库表:}但是,以下错误是返回的:“不允许相对路径使用副本到文件”,
我从我所理解的当我发送此请求时,我的VSCODE终端或其他任何内容都不会发生任何事情。
我尝试了:
“复制tag_7z8eq73 to stdout csv header”
“ copy tag_7z8eq73 to stdout”
“” \ copy copy tag_7z8eq73 to stdout''s stdout''
等等。.
您知道您知道Query允许我使用我的node创建.csv文件。 JS应用程序?
感谢您的帮助!
I made a function so that when I click on a button it made a "COPY TO" querie to the server. The goal is to export a table database 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"
From what I understand I have to write to STDOUT but when I send this request nothing happens in my VScode terminal 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?
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我没有使用复杂的“复制到命令行,我选择”数据库,而是将其推入数组,将其转换为JSON,然后使用“ Vue-JSON-to-CSV”插件创建CSV文件。
Finally instead of doing with the complicated 'COPY TO' command line, I 'SELECT' the database, push it into an array, convert it to json and create a csv file using the 'vue-json-to-csv' plugin.