[Tutor] Get variable values

Mário Gamito gamito at gmail.com
Thu Feb 1 17:57:10 CET 2007

Hi Danny,

> Wait, wait, before we continue here: did you finally get things working 
> from your last question?
Yes, i got things working.
That was just a test for python-MySQldb.

Now, i'm trying to get info from a python file, but i'm unable to get 
the variable values to insert in MySQL.

For example:

# Source field: save both url and value
                 if entry[key].has_key("value"):
                     self.set_as_string(key + "_name", entry[key].value)
                 if entry[key].has_key("url"):
                     self.set_as_string(key + "_link", entry[key].url)

                     db = MySQLdb.connect(host="localhost", 
user="planet", passwd="secret", db="planet_geek")
                     cursor = db.cursor()
                     cursor.execute("INSERT INTO blog_posts (title) 
VALUES ('entry[key].url')")

This isn't working.
It inserts nothing in the database.

How to retrieve the value of url ?

Warm Regards,
Mário Gamito

More information about the Tutor mailing list