471,086 Members | 825 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

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("username", "")
message = form.get("message", "")
attachment = form.get("attachment", None)
c.execute("""INSERT 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('attachment', '\x89PNG\r\n\x1a\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.

Apr 10 '08 #1
0 1181

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dave | last post: by
1 post views Thread by wolf | last post: by
3 posts views Thread by bissatch | last post: by
6 posts views Thread by Little | last post: by
1 post views Thread by treelife | last post: by
2 posts views Thread by Scott | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.