MySQLdb, blobs, and inserting

marut at my-deja.com marut at my-deja.com
Thu Jan 13 16:31:50 EST 2000


In article <85k0fd$hv2$1 at news1.xs4all.nl>,
  boud at rempt.xs4all.nl wrote:
> 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
>

I think the problem is quoting. How can I quote/escape all of the
special characters in my BLOB?


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list