mod_python and storing binary form data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • canistel@gmail.com

    mod_python and storing binary form data

    Hi, I have a little python webservice that I created, and in one of
    the methods I need to store some binary data that was "posted"... I
    want to do something like this, but it doesn't work.

    username = form.get("usern ame", "")
    message = form.get("messa ge", "")
    attachment = form.get("attac hment", None)
    ....
    c.execute("""IN SERT INTO Message (username, message, attachment)
    VALUES (%s, %s, %s)""", (username, message, attachment))


    "attachment " is then some binary data that was posted, but when I look
    in the mysql database, I see values for the attachment field which
    look like:

    Field('attachme nt', '\x89PNG\r\n\x1 a\n\x00\x00\...

    so it is storing something, just not my binary data (in this case a
    picture). the attachment column is a longblob in mysql.

Working...