Re: Inserting into the blob

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Rob Sargent <robjsargent(at)gmail(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Inserting into the blob
Date: 2019-06-10 16:16:36
Message-ID: CA+FnnTyjE3CEWiN3i9_-eSz_bAzio-xNiYL_a1RPO-D1_p34oQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, David,

On Mon, Jun 10, 2019 at 10:45 PM David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Mon, Jun 10, 2019 at 8:32 PM Rob Sargent <robjsargent(at)gmail(dot)com> wrote:
>>
>> > On Jun 10, 2019, at 6:40 AM, Igor Korot <ikorot01(at)gmail(dot)com> wrote:
>> >
>> > Hi, Adrian,
>> >
>> >> On Mon, Jun 10, 2019 at 7:03 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> wrote:
>> >>
>> >>> On 6/10/19 9:30 AM, Igor Korot wrote:
>> >>>
>> >>> According to https://stackoverflow.com/questions/16048649/postgresql-9-x-pg-read-binary-file-inserting-files-into-bytea,
>> >>> the file needs to be on the server inside PGDATA directory.
>> >>> It is not a problem in general, but just curious - is there a more
>> >>> generic solution (to get the file from the client)?
>> >>
>> >> This would depend on what is is you are trying to accomplish:
>> >>
>> >> 1) Are you really wanting to insert a file at a time at the psql command
>> >> line?
>> >
>> > Yes.
>> Gnarly. I suppose you could open the pdf in emacs and tell emacs to NOT render it. Cut the entire buffer and paste it, properly quoted, into your psql command line. But \lo stuff seems much more likely to work.
>>
>
> This is what I've used for text:
>
> \set file_content `cat './file.txt'`
> SELECT:'file_content';
>
> For smallish files I'd probably just stick with the same theme but encode the binary data as Base64 and then decode it into the bytea field.
>
> For not-so-small files probably better off storing the content elsewhere and inserting location data into the database.
>
> I have not yet had the desire to incorporate the large object API into my designs.

You are lucky you didn't work with the face databases...
Or photographs...

Thank you.

>
> David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Igor Korot 2019-06-10 16:30:42 Re: Inserting into the blob
Previous Message Evaldas Užpalis 2019-06-10 14:48:27 found xmin * from before relfrozenxid *