From: Adrian Klaver <adrian.klaver@aklaver.com>
To: David Gauthier <davegauthierpg@gmail.com>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Insert binary file into bytea where PG server does not have access to the file ?
Date: Fri, 3 Dec 2021 12:37:06 -0800
Message-ID: <58ae5076-2faa-db4a-2919-9d2ffc650fdd@aklaver.com> (raw)
In-Reply-To: <CAMBRECChKQYW-8COeNiMt09dJcX9YqHc9rmVMuTQtg-=iZ2sBg@mail.gmail.com>
References: <CAMBRECChKQYW-8COeNiMt09dJcX9YqHc9rmVMuTQtg-=iZ2sBg@mail.gmail.com>
On 12/3/21 12:13, David Gauthier wrote:
> 11.5 on linux
>
> Big corp with an IT dept providing us with PG DBs running in instances
> on their servers. (We/I amd not DBA). We on the client side, the
> "users" of these DBs, want to load binary files into bytea type
> columns. But the files we want to load are on disks that the server
> does not have access to.
>
> I googled around for a solution. This failed...
>
> insert into test_bytea (id,data) values
> (1,pg_read_binary_file('/top/next.whatever/xyz.bin')::bytea);
>
> ERROR: could not stat file "/top/next.whatever/xyz.bin": No such file
> or directory
>
> Understandable because the server hasn't even mounted /top.
>
> Is there a way to do what I want from the client side ?
Are you using some client side language(Java, Python, etc) library?
They generally have a way to deal with this:
Python via psycopg2:
https://www.psycopg.org/docs/usage.html#adapt-binary
Java via JDBC:
https://jdbc.postgresql.org/documentation/head/binary-data.html> If the file is transformed into some titanic string on the client side,
> then passed along over the net to the server in the insert statement, is
> there a max string length that I need to worry about ?
>
> Thanks
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, davegauthierpg@gmail.com
Subject: Re: Insert binary file into bytea where PG server does not have access to the file ?
In-Reply-To: <58ae5076-2faa-db4a-2919-9d2ffc650fdd@aklaver.com>
References: <CAMBRECChKQYW-8COeNiMt09dJcX9YqHc9rmVMuTQtg-=iZ2sBg@mail.gmail.com> <58ae5076-2faa-db4a-2919-9d2ffc650fdd@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox