[Zope-DB] retrieving images from MySQL
lmk at uvic.ca
Wed Jun 2 15:04:58 EDT 2004
I am attempting to retrieve a jpeg image I placed in a LONGBLOB field of a
MySQL database. I have all the correct packages installed in Zope to
connect to a MySQL database, and the connection is successful - I am able
to get text information out of the database. I have followed the
instructions listed in the MySQL HowTo by murphy
(http://www.zope.org/Members/murphy/MySQL-BLOBs), to retrieve images, but
I can't seem to get the image to display.
The image was placed in the database using a perl script. Attempting to
retrieve it using PHP is successful, so I assume that the uploading part
of the process is correct.
To retrieve it in Zope, I am doing the following:
I have a Z SQL Method called get_grid_map which is as follows (note there
is only one column in this table):
SELECT time,map FROM status_map
I then have a python script called create_grid_map, to execute the Z SQL
result = context.get_grid_map()
Trying to view the script results in the following error:
be displayed, because it contains errors.
I have thought maybe an image tag in another file was necessary, but
placing the image tag <img src="create_grid_map"> in dtml, page_template,
and plain html documents all result in a broken image.
One thing I notice that is suspicious is that when I view the result of
testing my SQL statement, the image contents are "array('c','--binary
image data--'), where --binary image data-- is just a lot of binary
stuff. I'm wondering where the array part is coming from, and if that
could be my problem. When I tried verifying things in PHP and created a
file from the database contents, there was no array string prefixed and
the file displayed correctly.
Any help would be very much appreciated. Thanks!
More information about the Zope-DB