Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute COPY command in remote database using local file

I'm trying to execute the Postgres COPY command.

COPY warehouse_terminal.test_table FROM 'C:\file.csv' DELIMITERS E'\t'
     CSV HEADER QUOTE E'\"' ESCAPE E'\\' NULL AS '';

The problem is, the db where I'm going to use this is remote, and the file "file.csv" is in my local machine in C:\. As a result, the file is not read.
Remote db, but local file. How can I get this working?

like image 968
muffin Avatar asked Sep 28 '26 13:09

muffin


1 Answers

Use \copy of the psql client on your local machine, it's a wrapper for SQL COPY for just this purpose.

See:

  • Problems while importing a txt file into postgres using php
like image 89
Erwin Brandstetter Avatar answered Oct 01 '26 03:10

Erwin Brandstetter