Hey dudes

This code worked fine

The one you gave me worked as well but when I wanteed to store it in the database it says that the packet was too large

Whit this code it doesn't complain but now I don't know  how to retrieve the image

This is what I'm doing:

import MySQLdb

import Image

import Image

from StringIO import StringIO

im = Image.open("auto.jpg")

outFile = StringIO()

im.save(outFile, "JPEG")

db=MySQLdb.connect(connection string)

cursor=db.cursor()

cursor.execute("insert into image values('',%s)",outfile)

ima = Image.open(outFile) >######

Then I retrieve it like this:

db=MySQLdb.connect(connection string)

cursor=db.cursor()

cursor.execute("select * from image")

res=cursor.fetchall()

Now I have the binary string in res[1] but when I try to open it it gives me an error (I'm sorry I'm not in the machine that has the database and I forgot to copy the error :/)

the fields in MySQL version 4 are Cod_Imagen int(4) auto_increment primary key, data longblob)

Thanks in advanced

Alberto



 
>From: Kent Johnson <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] Support >Date: Fri, 08 Apr 2005 15:04:42 -0400 > >Alberto Troiano wrote: >>Thanks >> >>Apparently it worked but one question do >> >>What kind of data is the return of the function tostring()???? > >It's a string >> >>Can i put it in a blob type of a database????or maybe in a >>longtext?? > >I would try longtext. > >Kent > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to