Missing Images

Carsten Haese carsten.haese at gmail.com
Sat Dec 26 16:52:43 EST 2009


Victor Subervi wrote:
> Right. Thank you again. I'd forgotten to put in
> enctype="multipart/form-data". Now I have the following snipped:
> 
>       for pic in ourPics:
>         sql = 'update %s set pic%d=%s where ID="%s";' % (store, i,
> (MySQLdb.Binary(pic),), id)
>         print sql
> #        cursor.execute(sql)

This binds the name <<sql>> to a string containing an "update" statement...

> Which prints to screen the following:
> 
> insert into products (SKU, Category, Name, Title, Description, Price,
> SortFactor, Availability, OutOfStock, ShipFlatFee, ShipPercentPrice,
> ShipPercentWeight, Associations, TempPrice, LastDatePrice, Weight,
> Metal, PercentMetal, pic0, pic1, sizes, colorsShadesNumbersShort)
> values("prodSKU1", "prodCat1", "name1", "title1", "descr", "12.34",
> "500", "1", "0", "10.00", "5", "2", "", "1", "2000-01-01", "2.5", "",
> "20", "�����JFIF��H�H����

...and that's an "insert" statement, so that's clearly not the output
from the code you posted above.

> and a bunch more binary data. This fails on insert. If I recall
> correctly, I need to convert that binary data into something like (c,
> array(... How do I do that? I'll include all code below in case it's
> necessary.

You have been told many, many times before, by myself and others, not to
embed values directly into the query string. Use parameter binding to
transmit the values to the database. I'm sure you'll find an old post of
mine somewhere in the archives of this list in which I showed you how to
do that.

--
Carsten Haese
http://informixdb.sourceforge.net




More information about the Python-list mailing list