---------- Forwarded message ----------
Date: Fri, 02 Feb 2007 00:52:49 +0000
From: "[ISO-8859-1] Mário Gamito" <[EMAIL PROTECTED]>
To: Danny Yoo <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Get variable values  [Introduction to Planet RSS news
    aggregator]

Hi Danny,

Thank you for your insightful info.

Now i'm getting somewhere.

I've made this mysql.py teste script:

import planet
import ConfigParser
import MySQLdb

db = MySQLdb.connect(host="localhost", user="planet", passwd="secret", db="planet_geek")
cursor = db.cursor()

config = ConfigParser.ConfigParser()
p = planet.Planet(config)
c = planet.Channel(p, "http://blog.gamito.org/rss.php?blogId=1&profile=rss20";)
c.update()
print len(c.items())

for item in c:
   print item.title
   cursor.execute("INSERT INTO blog_posts (title) VALUES (item.title)")
   print item.content

it prints the info from the feeds to the screen, but get an error from MySQL:
"File "sql.py", line 16, in ?
    cursor.execute("INSERT INTO blog_posts (title) VALUES (item.title)")
File "/usr/local/lib/python2.4/site-packages/MySQLdb/cursors.py", line 163, in execute
    self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.4/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1109, "Unknown table 'item' in field list")"

which means that the variable item.title is not recognized as a variable.

Any ideas ?

Warm Regards,
Mário Gamito
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to