How to read a binary file into a mysql table
Benoit
benoit.barberousse at gmail.com
Sat Dec 15 05:51:20 EST 2007
More information about the Python-list mailing list
Sat Dec 15 05:51:20 EST 2007
- Previous message (by thread): How to read a binary file into a mysql table
- Next message (by thread): How to read a binary file into a mysql table
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Dec 14, 5:41 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote: > En Fri, 14 Dec 2007 12:19:41 -0300, Hans Müller <HeinT... at web.de> escribió: > > > I cannot read a binary file into a mysql database. Everything I tried > > did not succeed. > > > What I tried (found from various google lookups...) is this: > > > con = MySQLdb.connect(to server) > > cur = con.cursor() > > > cur.execute("insert into data values('file1', %s)", (open("test.jpg", > > "rb").read(), )) > > Try wrapping the file contents with a Binary object (untested): > > data = MySQLdb.Binary(open("test.jpg","rb").read()) > cur.execute("insert into data values('file1', %s)", (data,)) > > -- > Gabriel Genellina I was suprised at what I could stick into a MySQL database. Also, you might wanna compress the binary for database performance.
- Previous message (by thread): How to read a binary file into a mysql table
- Next message (by thread): How to read a binary file into a mysql table
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list