K
K
Krava2019-01-16 17:16:11
PostgreSQL
Krava, 2019-01-16 17:16:11

PostgreSQL using COPY on remote DB?

Good afternoon, I encountered such a phenomenon as using COPY in postgres. I uploaded and updated large prices ~ 5 million. The problem arises in the fact that in production the database will be transferred to another server.
In PHP scripts, I use COPY , but this command does not work if the database is not on localhost.
What can you advise in this case, how to be?
PS, there are such thoughts:
1) you can make sure that the database is local
2) you can use exec psql -c -h ...., but in this case it will not work to make a transaction
3) you can look towards master -> slave replication

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rickkk, 2019-01-18
@Rickkk

What is stopping you from executing your php script with COPY on a remote server via ssh connection? You can also run a psql command over the same connection. At the end of a transaction with COPY, you can save the success flag of this transaction in some database table and check it from the main server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question