store binary files in mysql

Dragos Chirila d.chirila at
Tue Oct 12 11:55:45 CEST 2004


Use escape_string method from MySQLdb module.


Ivan Horvath wrote:
> Dear All,
> i would like to store binary file contents to a mysql database in a 
> mediumblob fields.
> i've got problem when there is a simple quote, double quot, backslash or 
> NUL character in the file content, because these characters are 
> acceptable by mysql only when there is an escape char. before it.
> do you know any solution, how can i replace these characters in order to 
> import it to a mysql table?

Dragos Chirila
Programmer, Finsiel ROMANIA
44A, Ficusului St. - 71544 Bucharest
Tel: +40 21 2320193
Fax: +40 21 2329807
Jabber: dragos at

More information about the Python-list mailing list