gpt4 book ai didi

linux - psql export 当文件存在时返回 No such file or directory

转载 作者:IT王子 更新时间:2023-10-29 01:20:50 26 4
gpt4 key购买 nike

我跑

psql -E -U siteportal -d portal -h 172.19.242.32 -c "COPY externals (id,logo_path,favicon_path,cover_path,header,description,sign_enable,sign_text,footer_logo_enable,footer_logo_path,footer_text,created_at,updated_at) FROM '/Applications/MAMP/htdocs/code/site/portal/public/csv/externals.csv' DELIMITER ',' csv;"

我得到了

ERROR:  could not open file "/Applications/MAMP/htdocs/code/site/portal/public/csv/externals.csv" for reading: No such file or directory

但我确定文件在那里,因为当我运行时

cat /Applications/MAMP/htdocs/code/site/portal/public/csv/externals.csv

我得到了

1,"/images/account/operator/logo.png","/images/account/operator/favicon.png","/images/account/operator/external.png","site Portal","Log in using your credentials",1,"This is a secure page",1,"/images/account/operator/footer_logo.png","© 2017 site Networks Inc.","2016-12-22 13:37:42","2017-01-31 14:22:11"

是因为权限吗?

-rwxrwxrwx@ 1 site  staff    307 May 24 13:46 externals.csv

我什至尝试使用 chomd 777 并使用 sudo 运行。但似乎没有任何帮助!

最佳答案

copy 更改为 \copy ( https://www.postgresql.org/docs/current/static/app-psql.html#APP-PSQL-META-COMMANDS-COPY )。稍微不同的命令,可让您将文件复制到服务器或从文件复制到服务器。

这里不同的原因是因为您连接到远程服务器(我假设),但导入本地文件。


另一种选择是传递你的文件并让 psql 从标准输入读取

 -c "copy externals (id,logo_path,favicon_path,cover_path,header,description,sign_enable,sign_text,footer_logo_enable,footer_logo_path,footer_text,created_at,updated_at) from STDIN with delimiter as ','" < /Applications/MAMP/htdocs/code/benu/ssc-portal/public/csv/externals.csv

关于linux - psql export 当文件存在时返回 No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44165527/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com