2017-05-24 3 views
6

je lance

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;" 

Je suis

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

Mais je sais que le fichier est là, becase quand je lanceexport psql retour Aucun fichier ou répertoire lorsque le fichier existe

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

J'ai reçu

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" 

Est-ce à cause de la permission?

[email protected] 1 site staff 307 May 24 13:46 externals.csv 

J'essaie même chomd 777 et courir avec sudo. Mais rien ne semble aider!

+0

est l'accès aux fichiers bloque SELinux? –

Répondre

6

Remplacez copy par \copy (https://www.postgresql.org/docs/current/static/app-psql.html#APP-PSQL-META-COMMANDS-COPY). Commande légèrement différente qui vous permet de copier vers/depuis un fichier vers votre serveur.

La raison de la différence est que vous vous connectez à un serveur distant (je suppose), mais que vous importez un fichier local.


Une autre option est de passer votre fichier et ont psql lu sur stdin comme

-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