0

i am trying to use copy command in SQL and this error is showing

ERROR: could not open file "C:\Users\HI\AppData\Local\Temp\Temp2_sql_resource.zip\data1\students.csv" for reading: Permission denied 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: 42501

see my code below

DROP TABLE if exists studentlist;

CREATE TABLE studentlist(
    studentid SERIAL NOT NULL,
    stname VARCHAR(50),
    email VARCHAR(150),
    birth DATE,
    entrydate DATE,
    gender VARCHAR(10),
    classnum INT);

COPY studentlist(stname,email,birth,entrydate,gender,classnum )
    FROM 'C:\Users\HI\AppData\Local\Temp\Temp2_sql_resource.zip\data1\students.csv'DELIMITER','CSV HEADER;
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • The error is because the Posgtres server cannot read that file inside its `c:\users\HI\AppData\...` folder. Maybe the server does not have permission to read inside that folder. Also, this file you try to load is _inside_ a zip file. This is also a red flag to me. Can you uncompress this into another folder? – Iñigo González Nov 11 '21 at 17:07
  • The highest-voted answer in the linked question has detailed steps to resolve this error. – Bill Karwin Nov 11 '21 at 17:08

0 Answers0