[DB-SIG] MySQLdb -- BLOB is array

Andy Todd andy47 at halfcooked.com
Tue Jul 26 14:33:08 CEST 2005

GMane Python wrote:
> Hello all.
>   I'm new to python, and to Mysql, too.  I'm trying stuff out, and wanted to
> take a photo in a program and insert it into a MySQL table as a BLOB.  When
> trying to retrieve it, I get an array('c', <PIL Image instance>).
>   I do a result = cursor.fetchall(), but how can I get the <PIL Image
> instance> from  the result array?
> Thank you!
> Dave


It's probably easier if you provide some sample code to illustrate your 
problem and any error messages you observe when you try and run it.

 From the brief description you've given it seems that you may need to 
read the tutorial on sequences and lists [1] because this is what is 
returned from a 'fetchall' method. Take a look at the DB-API 2.0 
documentation [2] for information about this.

It looks like the MySQLdb module is managing to figure out that you've 
stored a photo in the database and returned it as an appropriate object. 
Have you got the Python Imaging Library [3] installed? Because that's 
what you need to work with your photo.

[1] http://docs.python.org/tut/node7.html#SECTION007300000000000000000
[2] http://www.python.org/peps/pep-0249.html
[3] http://www.pythonware.com/products/pil/

 From the desk of Andrew J Todd esq - http://www.halfcooked.com/

More information about the DB-SIG mailing list