By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,274 Members | 2,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,274 IT Pros & Developers. It's quick & easy.

StringIO MySQL data blob Image problem

P: n/a
Hi,

I am trying to insert an image, which is stored as a blob in MySQL,
into a table using Reportlab.

I have tried this:
from StringIO import StringIO
cfoto = StringIO(result[0][1]) # where result[0][1] is the 'blob'
cfoto.seek(0)
foto=cfoto.getvalue

But when I do:
print foto, I see something similar to this:
array('c','\xff\xd8\............etc.......etc..... .')
This is also the string I see in the table, in stead of the actual image.

I have tried:
cfoto StringIO()
cfoto.write(result[0][1].tostring())
foto=cfoto.getvalue()
that returns:
lboq5\Y|A*,"m3Zf ""N,*It"b5@xq'ksd͏1 ؜
^J*C(r){:t_jo
C(c)[)gNXi etc... etc...
and return an UnicodeDecodeError when I try to insert this into the table

Any ideas or clues someone? Your help is appreciated.
Dimitri
(BTW, the MySQL image blob is valid, it shows up in MySQL Query Browser)

--
---
You can't have everything. Where would you put it? -- Steven Wright
---
please visit www.serpia.org
Sep 5 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.