Matias
Matias

Reputation: 1

import data from CSV into a Postgres table using pgAdmin 3

COPY des_unificado (cedula, grupo, nivel, insti, sector, dpto, zona, ccorres, apel_corto, digito_id, nombre, cargo, pres_act, turno, tipo_rubro, catego_psp, cant_rubro, presupuesto_ant, devenga_ant, aporte_ips, aporte_bnt, ac_meses, ac_aguinal, f_mm_ing_c, f_aa_ing_c, opera_lqd, tipo_rgtro, status_crg, aa_plan, mm_plan, jubilac, rec_ant, ccorr, orden, antece_nro, resolu_nro, estado, insti_ant, id_grado_c, seccion, id_especia, multa, judicial, afemec, otros_dec, presupuesto, afemec_1, liquido, dcto_jub, monto_defi, aux, linea)
FROM '/home/arturo/Escritorio/des_unificado1.csv' 
WITH DELIMITER ';'
CSV HEADER

Can someone help me, when you run these commands, I get the following error:

ERROR:  could not open file "/home/arturo/Escritorio/des_unificado1.csv" for reading: No such file or directory

********** Error **********

ERROR: could not open file "/home/arturo/Escritorio/des_unificado1.csv" for reading: No such file or directory
SQL state: 58P01

Upvotes: 0

Views: 1358

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324951

COPY expects the file to be on the database server, not the database client. So if you're connecting to a server on a different computer and the file is on your computer, the file doesn't exist for the server.

If you want the file to be on the database client, you can use the psql command \copy. See \? for details.

This is a part of the psql command line client, not the server. Internally it uses COPY ... FROM STDIN and reads the file then sends it to the server over the PostgreSQL connection.

Upvotes: 1

Related Questions