相对路径不允许使用复制到文件

发布于 2025-02-12 17:55:31 字数 753 浏览 0 评论 0原文

我制作了一个函数,以便当我单击一个按钮时,它将“副本”到服务器的“ 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

俏︾媚 2025-02-19 17:55:31

最后,我没有使用复杂的“复制到命令行,我选择”数据库,而是将其推入数组,将其转换为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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文