[PyGreSQL] Storing images/documents in bytea fields as base64 encoded strings
G. Skerrett
imageguy1206 at gmail.com
Mon Jan 1 10:57:14 EST 2007
On 12/30/06, Sean Davis <sdavis2 at mail.nih.gov> wrote:
> G. Skerrett wrote:
> > We have are developing an internal application to store documents and
> > images in the postgresql db.
> > After struggling with escaping the low order characters for
> > including in the bytea field, we hit upon the idea of simply using the
> > python base64 modules to encode files as base64 strings and store the
> > string in the database.
> >
> > We think that the benefit is doing this is;
> > 1) using an industry standard encoding mechanism so they could be
> > decoded with another application if desired.
> > 2) the images/documents are "web/email ready", so storing and encoding
> > stage will encur a penalty hit, hwoever, the retreival will not.
> >
> > If any one on this list has suggestions/comments or can see a problem
> > with this strategy, we would appreciate comment.
> I think this is a pretty common approach. You can also store
> base64-encoded in a simple TEXT field. If you want the DB to do the
> work, look here:
>
> http://www.postgresql.org/docs/current/static/functions-string.html
>
> Sean
> _______________________________________________
> PyGreSQL mailing list
> PyGreSQL at Vex.Net
> http://mailman.vex.net/mailman/listinfo/pygresql
>
Thanks Sean.
After posting the message here I found the postgresql ng list on line
and after a search arrived at the same sentiment.
Seem the only "negative" would be that base64 requires approx 30% more
space that the regular binary file.
Also had an opportunity to check out the "TOAST" funcitonality.
-- have you had any experience with this. ??
Looks to me like it was just added in v8.1
More information about the PyGreSQL
mailing list