String Literal to Blob
victorsubervi at gmail.com
Wed Apr 9 20:29:21 CEST 2008
On Wed, Apr 9, 2008 at 1:49 PM, Steve Holden <steve at holdenweb.com> wrote:
> Victor Subervi wrote:
> > On Wed, Apr 9, 2008 at 12:51 PM, Steve Holden <steve at holdenweb.com
> > <mailto:steve at holdenweb.com>> wrote:
> I imagine the following code should do so, given your earlier writings:
> #! /usr/bin/python
> import MySQLdb
> print "Content-type: image/jpeg\r\n"
> host = 'host'
> db = 'bre'
> user = 'user'
> passwd = 'pass'
> connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)
> cursor = connection.cursor()
> cursor.execute('select img from photo where id="7";')
> content = cursor.fetchall()
> f = open("somefile.jpg", "w")
> Then see if you can deal with "somefile.jpg" like any other JPEG. If you
> can't then your blobs are somehow being mangled. If you can, we'll take
> it from there.
Yes, I can. Shows up in browser when surfed to, and it was pulled from the
database. No mangling. I am signing off, back tomorrow morning.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list