Postgresql, csv file import

Asked

Viewed 83 times

0

I am having a lot of difficulty trying to import the CSV file using PostgreSQL, apparently the program is not able to read the file, but granted permission in all users and folders of the operating system and the program itself.

I saw on some site to use this syntax, but it shows error when executing the command.

psql\copy maquinas

from 'E:\Mídia\Cursos\SQL Server\Postgres\LogMaquinas.csv'

delimiter ','

csv header;

Follow message that appears when trying to execute

inserir a descrição da imagem aqui

  • this file exists in the folder?

  • try changing each \ by two \\ in the file name: 'E: Media Courses SQL Server Postgres Logmaquinas.csv' - I can’t confirm now if this is the case for postgresql, but many programming languages reserve the \ as an escape character to put special characters in the string. (inclusive to quote a single \ here at stackoverflow gives problem - need to put a space together)

  • Note that the suggested is to run the command \copy customer’s psql, I don’t think psql is running, but some other client program is running. I think I’m running the command COPY on the server machine and not on the client https://www.postgresql.org/docs/current/sql-copy.html.

  • As jsbueno commented the manual, in the documentation of the SQL COPY command it says: "filename The path name of the input or output file. An input file name can be an Absolute or relative path, but an output file name must be an;"

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.