Sorry, Copy Paste error
I did that
cursor.execute("insert into image values('',%s)",outfile.getvalue())
My question now is where should I have to retrieve the database value to show the image?????
And another question yet:
I'm making this application to run as a daemon under Linux (the linux part is not a problem)
How can I make my application to start when the OS start???
and How can I make my application to check every x time if it has photos to store?
Is it more efficient to store the data in the database (we're talking about thousands of images) or the path and the photos in HD????
Thanks in advanced
Alberto
>From: Danny Yoo <[EMAIL PROTECTED]> >To: Alberto Troiano <[EMAIL PROTECTED]> >CC: [EMAIL PROTECTED] >Subject: Re: [Python-Help] Support with Image >Date: Sat, 9 Apr 2005 14:37:03 -0700 (PDT) > > > Hey Danny it worked!!!!!!!! > >Hi Alberto, > >Good, I'm glad that it's working now. > > > > > but now I don't know how to retrieve the image > > > > This is what I'm doing: > > > > import MySQLdb > > import Image > > from StringIO import StringIO > > im = Image.open("auto.jpg") > > outFile = StringIO() > > im.save(outFile, "JPEG") > >Ok, looks good so far. At the end of this, outFile is a file-like object >whose content should be that JPEG image. > > > > db=MySQLdb.connect(connection string) > > cursor=db.cursor() > > cursor.execute("insert into image values('',%s)",outfile) > >This last statement is problematic. Remember: outFile is a StringIO >object, not a string. A StringIO object responds to a str() call with >the following: > >###### > >>> from StringIO import StringIO > >>> s = StringIO("hello world") > >>> s ><StringIO.StringIO instance at 0x41d00> > >>> str(s) >'<StringIO.StringIO instance at 0x41d00>' >###### > > > >So we can't use the default. We have to be more specific and use >getvalue() to get at the content: > >###### >cursor.execute("insert into image values('',%s)",outfile.getvalue()) >###### > > >Hope this helps! >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor