__MagicPower
Do one thing and do it best!

导航

 
#!/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

posted on 2016-01-05 16:14  __MagicPower  阅读(148)  评论(0编辑  收藏  举报