Пробую писать блобы в mysql с помощью MySQLdb. Ничего не получается.
>>> db.cursor().execute('CREATE TABLE t(v LONGBLOB)')
0L
>>> file = open('1.jpg', 'rb').read()
>>> db.cursor().execute("INSERT INTO t (v) VALUES (%s)" % file)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 173, in execute
self.errorhandler(self, exc, value)
File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\xff\xd8\xff\xe0' at line 1")