MySQL blobs confusion

deelan ggg at zzz.it
Fri Nov 5 03:25:54 EST 2004


Kirby Urner wrote:
> I've been testing the Cookbook example 8.6 (2002 edition) re using cPickle to
> insert and retrieve BLOBs from mySQL, using Python's MySQLdb module.
> 
> When I try to cPickle.loads(blob), I get an error telling me that loads wants a
> string, not type array.array.  So I go cPickle.loads(blob.tostring()) instead
> and it works.

see bug:
<http://sourceforge.net/tracker/index.php?func=detail&aid=975831&group_id=22307&atid=374932>

''Cursor returns array instead of string for blob column type
The standard cursor class ('Cursor') used to return
MySQL blob row types as Python string values. In
version 1.0 it returns arrays containing a single item
with the string 'c' as key and the blob string as the
value.''


BTW i'm using this code:

pickle.loads(row['meta'])

to unpickle a blob field (in the 'meta' column)
from a mysql4's MyISAM table and it works as-is.

i'm using both mysqldb 1.0.0 (dev box) and
1.1.6 (on the server).

but i'm using DictionaryCursor instead of classic
return-as-tuples Cursor.

cheers,
deelan.

-- 
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://www.netspyke.com/> .



More information about the Python-list mailing list