Okay, here is where we find the fly in the ointment. If I run this code: #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'mysqldb2.ehost-services.com' db = 'benobeno_bre' user = 'benobeno' passwd = '21122112' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0] content = content.tostring() print content f = open("2.jpg", "w") f.write(content) f.close() all is well :) If, however, I change two lines to make it an html page:
#! /usr/bin/python import MySQLdb # print "Content-type: image/jpeg\r\n" print "Content-type: text/html\n" host = 'mysqldb2.ehost-services.com' db = 'benobeno_bre' user = 'benobeno' passwd = '21122112' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0] content = content.tostring() print '<img src="%s"><br /><br />' % content # print content f = open("2.jpg", "w") f.write(content) f.close() it prints garbage. It does not yield the image. Now, what? TIA. Victor
-- http://mail.python.org/mailman/listinfo/python-list