From: | Dmitriy Igrishin <dmitigr(at)gmail(dot)com> |
---|---|
To: | Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com> |
Cc: | Andre Lopes <lopes80andre(at)gmail(dot)com>, postgresql Forums <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Store base64 in database. Use bytea or text? |
Date: | 2011-01-25 22:49:25 |
Message-ID: | AANLkTimYZMr-jaqMz1eWzftE-ScDX1qgUipicGLV1hnu@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2011/1/26 Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>
> On 25 January 2011 22:27, Andre Lopes <lopes80andre(at)gmail(dot)com> wrote:
> > Hi,
> >
> > I need to put some images on Base64 in a PostgreSQL database. Wich
> > type should I use and what is the difference between using bytea or
> > text to store Base64?
>
> I really don't think you want to do that. Base64 is used to make
> binary data 7-bit safe for compatibility with legacy systems (i.e. to
> embed arbitrary binary data within ASCII). Sometimes people escape
> binary data as base64 to store it in their DB, but they typically
> store it as bytea. Base64 probably isn't even a particularly good
> choice for escaping binary, let alone storing it.
>
> You should just use a generic escaping function. libpq has
> PQescapeByteaConn(), for example.
>
It is better to use PQexecParams and binary data transfer instead
of escaping via PQescapeByteaConn.
>
> --
> Regards,
> Peter Geoghegan
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
--
// Dmitriy.
From | Date | Subject | |
---|---|---|---|
Next Message | Andre Lopes | 2011-01-25 22:52:42 | Re: Store base64 in database. Use bytea or text? |
Previous Message | Bill Moran | 2011-01-25 22:46:12 | Re: Store base64 in database. Use bytea or text? |