Re: copy file from a client app to remote postgres isntance

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: copy file from a client app to remote postgres isntance
Date: 2022-11-07 20:40:40
Message-ID: 34c71bc8-e4cc-05f8-c0e5-211754c55940@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/7/22 10:57, Вадим Самохин 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?

I'd write a small Python script, using the csv module to read the data and
psycopg2 to load it.

--
Angular momentum makes the world go 'round.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brad White 2022-11-07 20:59:09 Re: Setting up replication on Windows, v9.4
Previous Message Willian Colognesi 2022-11-07 20:29:07 Re: Segmentation Fault PG 14