Jump to content

help

- - - - -

  • Please log in to reply
No replies to this topic

#1
capoon

capoon

    Newbie

  • Members
  • Pip
  • 6 posts
I need to display image from database using python but when i run the code,
it dispay empty page, please help


#!c:/python25/python

import MySQLdb as mdb

import sys

# Import modules for CGI handling 

import cgi, cgitb 



print "Content-type:text/html\r\n\r\n"





try:

    conn = mdb.connect(host='localhost',user='mabel', 

        passwd='mabel10', db='test')


    cursor = conn.cursor()


    cursor.execute("SELECT pic FROM Images where Id=8")


    fout = open('baby3.jpeg','wb')

    fout.write(cursor.fetchone()[0])

    fout.close()


    cursor.close()

    conn.close()


except IOError, e:


    print "Error %d: %s" % (Data)(e.args[0],e.args[1])

    sys.exit(1)









1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users