Jonas Meurer wrote:
I've never tried extensively to use images inside a database (too slow for most of my uses), but I thought I'd drop in to point out that you should, for security reasons, be using place holders on your sql. It might just fix your image problem as well, but I don't know. Also, converting a binary image into a string doesn't seem like it would be wise, but like I said, I've never tried it. At any rate, your function would look like this:def i_update(image, imgid): image = "%s" % (image) sql_exec = """UPDATE Images SET Image='%s' WHERE ImgID = '%s' """ % (image, imgid) o = open("/tmp/file.jpg", "w") o.write(image) o.close() db_connect.cursor.execute(sql_exec)
def i_update(image, imgid):
image = "%s" % (image)
o = open("/tmp/file.jpg", "w")
o.write(image)
o.close()
db_connect.cursor.execute("""UPDATE Images SET Image=%s WHERE ImgID=%s""", (image, imgid))
-- http://mail.python.org/mailman/listinfo/python-list