473,657 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

StringIO MySQL data blob Image problem

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.getv alue

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(res ult[0][1].tostring())
foto=cfoto.getv alue()
that returns:
lboq5 \Y|A *,"m3Z f""N,* It"b5@x q'ksd ͏1؜
^J*C(r){:t _jo
C(c)[)gNXi etc... etc...
and return an UnicodeDecodeEr ror 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
0 2120

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7426
by: Sugapablo | last post by:
Is there any PHP function that will allow me to determine the MIME type of a blob stored in MySQL? Specifically, if I'm storing an image as a blob in MySQL, is there any PHP function that can determine whether it's a gif, jpeg, png, etc? -- http://www.sugapablo.com <--music ] http://www.sugapablo.net <--personal ]
3
3135
by: NotGiven | last post by:
I am researching the best place to put pictures. I have heard form both sides and I'd like to know why one is better than the other. Many thanks!
6
2812
by: matt roberts | last post by:
Hello, I am parsing a mailbox using the imap functions, pulling out images attached and putting them into mySQL as BLOB fields. I am having problems displaying images once they are stored in mySQL, and I think it may be related to the way I store them. The following line of code is called after an attachment has been identified as a GIF attachment:
10
7392
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't recommend storing the image to the filesystem and only keeping a pointer to that in the table. I want to dump the image to a table. My code dumps the data into the table, however, I get the following error when trying to view the image "the image ......
10
13401
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without a problem. I am using chunk_split(data) and the base64_encode and base64_decode on the files. I do a select from the database, and then echo the image (with header(Content Type: image/jpeg) and the decoded image displays fine. Yes, I have...
3
5379
by: Taras_96 | last post by:
Hi everyone, I'm having a bit of trouble understanding the purpose of escaping nulls, and the use of addcslashes. Firstly, the manual states that: "Strictly speaking, MySQL requires only that backslash and the quote character used to quote the string in the query be escaped. This function quotes the other characters to make them easier to read in
0
423
by: dimitri pater | last post by:
---------- Forwarded message ---------- From: dimitri pater <dimitri.pater@gmail.com> Date: Sep 5, 2007 9:13 PM Subject: Re: StringIO MySQL data blob Image problem To: Tim Golden <mail@timgolden.me.uk> Dear Tim, you are right of course, I have been trying to put the StringIO in a temp file: cfoto=StringIO
221
367403
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files into the database, rather than just onto the file-system. Well, most of the time, you wouldnt. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the servers file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
4
8148
by: foss | last post by:
HI all, I am able to upload the image as blob to mysql. but while displaying the image i cant display it properly . The code used for uploading image to mysql inserts data into mysql table.The uploading code is: MYSQL_CONNECT("localhost","root",""); mysql_select_db("sample"); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $result=MYSQL_QUERY("INSERT INTO...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8622
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.