execute python code from db

Nick Coghlan ncoghlan at iinet.net.au
Wed Jan 26 14:12:20 CET 2005


robert wrote:
> Hello,
> 
> Anybody knows if it's possible to execute python code from an db.
> 
> db=MySQLdb.connect(host="localhost",user="r",passwd="j",db="v")
> 
> c=db.cursor()
> c.execute("""SELECT * FROM table
>             WHERE id = %s""", (id,))
> 
> for python_code in c.fetchall():
>     execute (python_code)
> 
> Maybe feed python with stdin??.

What's wrong with the exec statement?

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list