#!/usr/bin/env python #--*-- coding:utf-8 --*-- __author__ = 'Kevin' import MySQLdb as mdb import sys try: conn = mdb.connect('localhost','root','redhat','test') cursor = conn.cursor() cursor.execute("SELECT Data FROM Images LIMIT 1") fout = open('image.png','wb') fout.write(cursor.fetchone()[0]) fout.close() cursor.close() conn.close() except IOError,e: print "Error %d:%s" % (e.args[0],e.args[1]) sys.exit(1)
Result:
从你的项目文件夹中能找到该IMAGE