0
ERROR:  could not open file "C:\Program Files\PostgreSQL\10\data\Data_copy\student.csv" for reading: No such file or directory
HINT:  COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
SQL state: 58P01
1
  • You really should consider adding an explanation about what you are trying to do, also post any code you have, and what you have tried so far. Commented Jun 12, 2020 at 10:05

2 Answers 2

2

The error message says it all.

If you use SQL COPY command the file to be loaded must be accessible on database server side.

If this is not possible you can use psql CLI \copy command from the client side because it can access a file on client side.

Example:

$ cat t.csv
1,ONE
2,TWO
3,THREE

In psql:

# \d t
                     Table "public.t"
 Column |  Type   | Collation | Nullable | Default 
--------+---------+-----------+----------+---------
 x      | integer |           |          | 
 y      | text    |           |          | 


# \copy t from 't.csv' delimiter ',';
COPY 3

# select * from t;
 x |   y   
---+-------
 1 | ONE
 2 | TWO
 3 | THREE
(3 rows)
Sign up to request clarification or add additional context in comments.

1 Comment

Can you suggest an example?
0

Using psql run the following command

\copy students from 'C:\Program Files\PostgreSQL\10\data\Data_copy\student.csv' csv;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.