From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Вадим Самохин <samokhinvadim(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: copy file from a client app to remote postgres isntance |
Date: | 2022-11-07 18:24:46 |
Message-ID: | da571604-48ea-3c3e-d1df-53b4c1b2dc76@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 11/7/22 8:57 AM, Вадим Самохин wrote:
> Hi all,
> I have an application that must copy a local file in csv format to a
> postgres table on a remote host. The closest solution is this one
> (https://stackoverflow.com/a/9327519/618020
> <http://stackoverflow.com/a/9327519/618020>). It boils down to
> specifying a \copy meta-command in a psql command:
>
> |psql -U %s -p %s -d %s -f - <<EOT\n here hoes a \copy meta-command \nEOT\n
> ||
> and executing it. B|ut it's quite an unnatural way to write database
> code. Has anything changed in the last ten years? Or, is there a better
> wayto copy file contents in a remote database?
>
1) Set up postgres_fdw:
https://www.postgresql.org/docs/current/postgres-fdw.html
on local machine to point at table on remote machine and then \copy or
COPY to local machine.
2) Copy the CSV file to remote machine and then do \copy or COPY there.
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Willian Colognesi | 2022-11-07 18:36:22 | Re: Segmentation Fault PG 14 |
Previous Message | William Torrez Corea | 2022-11-07 18:14:55 | My account was locked in pgadmin4 |