I'm creating a program in Java to read an Excel file, remove some bad rows, create a CSV file from it, and insert it into PostgreSQL database by using COPY syntax. Currently it works if the file and database are in the same machine. I want to make it work if the database is in a remote machine. Is it possible with COPY syntax to grab the CSV file in the other machine to insert it in the database? Or are there another alternatives to do it?
Asked
Active
Viewed 316 times
0
-
Copy grabs the file you point it to, it doesn't care where it comes from and how. – Jakub Kania Oct 13 '15 at 10:07
1 Answers
0
Just connect to the database (with psql) from the server that contains the file and you can just do \copy mytable FROM foo.csv DELIMITER ','
.

Kayaman
- 72,141
- 5
- 83
- 121