MySQLdb, blobs, and inserting

Boudewijn Rempt boud at rempt.xs4all.nl
Thu Jan 13 02:56:29 EST 2000


marut at my-deja.com wrote:

>>>> c.execute(r"INSERT INTO items (story) VALUES (%s)" % file )
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> File "MySQLdb.py", line 153, in execute
> File "MySQLdb.py", line 189, in _query
> _mysql.OperationalError: (1064, 'You have an error in your SQL syntax
> near \'<!DOCTYPE HTML PUBLIC "-//W3C
> //DTD HTML 4.0 Transitional//EN" "http://www.w3.org\' at line 1')

I haven't tried it - but wouldn't 

...." % file.read() )

work? I mean, are you trying to insert a file object or the contents
of the file? What does the mysql log file show? It's quite possible
that that will enlighten you, since it shows the completed SQL
statement.
-- 

Boudewijn Rempt  | http://www.xs4all.nl/~bsarempt



More information about the Python-list mailing list