My hair... I am ready to tear it out.  I've been working with Python and the
MySQLdb module for a long time, thought I couldn't get snagged by anything,
but today I just can't seem to persuade the blasted thing to let me stick an
HTML document (a string) into a TEXT column.  I'm getting SQL syntax errors,
as though the document isn't properly escaped, even though I'm using
substitution so that MySQLdb should be taking care of that.  I'm wondering
if I'm missing something terribly obvious, because this is dead-simple code.
Here's the relevant bit and a couple of surrounding lines.

for url in urls:
        doc = urllib.urlopen(url[0]).read()
        dbh.execute("INSERT INTO rss_article (body,url) VALUES (%s, %s)",(doc,
url))
        dbh.execute("UPDATE rss_item SET cached = '1' WHERE url = %s",(url,))

It's retrieving the document just fine, resulting in a big ol' string (it
really is a string, I checked), but that string just won't go into the
database.  rss_article is a TEXT column in a MyISAM table.  I get an SQL
syntax error and MySQL tells me to check the syntax with a snippet from
right near the beginning of the HTML, where it has lots of (annoying, I
suppose) backslashes, quotes and other stuff that is a pain to encode
properly by hand.

Any help will be most gratefully accepted.  My hair will thank you, too.

Nick

--
Nick Arnett
Phone/fax: (408) 904-7198
[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to