[DB-SIG] BLOB data types

Andy Dustman farcepest at gmail.com
Sat Jan 1 10:06:33 CET 2005

On Fri, 31 Dec 2004 18:53:52 -0800, Robert Brewer <fumanchu at amor.org> wrote:
> Andy Dustman wrote:
> > What's the current view on the best object class to use for
> > Binary/BLOB objects? PEP-249 recommends buffer, but buffer
> > appears deprecated. MySQLdb used to strings, but currently
> > uses array. mxODBC appears to use strings. psycopg appears
> > to use buffer.

> Won't Python strings be encoded, and therefore often choke on values between 128 and 255? To my naive mind, unicode objects would be the preferred choice.

No. With MySQL, at least, the only meta-characters it cares about in
strings passed to it are single-quote ('), backslash (\), and NUL
(zero-byte), and all of these can be escaped with backslash, and there
is an API function to do this safely. You don't have to do this with
values you pass in; it happens automatically with MySQLdb. Getting
8-bit binary strings out of MySQL and into Python is not a problem

One reason Unicode objects weren't used because, when PEP-249 was
written, they didn't exist (IIRC).
Computer interfaces should never be made of meat.

Using GMail? Setting Reply-to address to <> disables this annoying feature.

More information about the DB-SIG mailing list