Thread: BYTEA or LO?

BYTEA or LO?

From
"Jean-Yves F. Barbier"
Date:
Hi list,

I need to read/write pictures to my DB and I wonder which column type
would be the best? (and DON'T feed the troll: I won't put them onto the FS),
client will be written in Python.

I formerly tested BYTEA (7.dontremember) and found that I needed to transcode
my pictures into Base64 format to be able to do so (long and add 33% to the
size); this is what I'd like to avoid.

Pictures will be written (rare), read (often) and deleted (rare), but
may be, one day, this program could have a web interface.

So what would be the best to my needs?

JY
--
You can build a throne out of bayonets, but you can't sit on it for very long.
        -- Boris Yeltsin

Re: BYTEA or LO?

From
"ktm@rice.edu"
Date:
On Tue, May 31, 2011 at 07:09:23PM +0200, Jean-Yves F. Barbier wrote:
> Hi list,
>
> I need to read/write pictures to my DB and I wonder which column type
> would be the best? (and DON'T feed the troll: I won't put them onto the FS),
> client will be written in Python.
>
> I formerly tested BYTEA (7.dontremember) and found that I needed to transcode
> my pictures into Base64 format to be able to do so (long and add 33% to the
> size); this is what I'd like to avoid.
>

That is needed to use the non-binary API. You can also use hex encoding starting
with 9.0, I think. The data is stored in binary internally so you should not get
a 33% bump in size. If you use the binary API, you can avoid the hex/base64
encoding pass as well.

Regards,
Ken

Re: BYTEA or LO?

From
"Jean-Yves F. Barbier"
Date:
On Tue, 31 May 2011 13:40:02 -0500, "ktm@rice.edu" <ktm@rice.edu> wrote:

...
> That is needed to use the non-binary API. You can also use hex encoding
> starting with 9.0, I think. The data is stored in binary internally so you
> should not get a 33% bump in size. If you use the binary API, you can avoid
> the hex/base64 encoding pass as well.

I just read the doc but didn't fully understand the binary part.

Do you mean that with BYTEA binary type I can directly R/W my pictures
without any transcoding trick?

--

Re: BYTEA or LO?

From
Merlin Moncure
Date:
On Tue, May 31, 2011 at 2:01 PM, Jean-Yves F. Barbier <12ukwn@gmail.com> wrote:
> On Tue, 31 May 2011 13:40:02 -0500, "ktm@rice.edu" <ktm@rice.edu> wrote:
>
> ...
>> That is needed to use the non-binary API. You can also use hex encoding
>> starting with 9.0, I think. The data is stored in binary internally so you
>> should not get a 33% bump in size. If you use the binary API, you can avoid
>> the hex/base64 encoding pass as well.
>
> I just read the doc but didn't fully understand the binary part.
>
> Do you mean that with BYTEA binary type I can directly R/W my pictures
> without any transcoding trick?

If you are using libpq or another driver that exports this feature of
the protocol, yes.

merlin

Re: BYTEA or LO?

From
"Jean-Yves F. Barbier"
Date:
On Tue, 31 May 2011 14:21:17 -0500, Merlin Moncure <mmoncure@gmail.com> wrote:

...
> > Do you mean that with BYTEA binary type I can directly R/W my pictures
> > without any transcoding trick?
>
> If you are using libpq or another driver that exports this feature of
> the protocol, yes.

YES! I just stumble upon this paper:
http://code.activestate.com/lists/python-list/595961/

Thanks to the both of you :)

JY
--