Insert blob data to MySQL
Steve Holden
sholden at holdenweb.com
Sat May 4 00:43:53 EDT 2002
"Billy Ng" <kwokng at earthlink.net> wrote ...
> Hi folks,
>
> Would any body tell me how to insert a blob object to the mysql blob field
>
Here "cc" is a cursor on a MySQLdb connection ...
>>> cc.execute("""CREATE TABLE blobtbl (
... i integer primary key auto_increment,
... b blob)""")
0L
>>> s = "string data but it could be anything"
>>> cc.execute("""INSERT INTO blobtbl (b) VALUES(%s)""", (s,))
1L
>>> cc.execute("""SELECT * FROM blobtbl""")
1L
>>> cc.fetchall()
((1L, 'string data but it could be anything'),)
>>>
Is this what you wanted?
must-remember-to-delete-that-table-ly y'rs - steve
--
Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/
More information about the Python-list
mailing list