> Is possible to create dynamic sql in a web.update query, e.g.
>
>  for i in range(10):
>       atn = "at"+str(i)
>       atn1 = "at"+str(i+1)
>       web.update('atab', $atn='$atn1', vars=locals())
>
> so the column name is dynamically updated on each iteration, e.g.
>
> at0 = at1
> at1 = at2
> ...
>
>   
import web
web.connect('sqlite',db=':memory:')
web.query('create table foo (name,age)')
web.insert('foo',name='Joseph',age=10)
joe = 'Joseph'
args = {'name':'bob', 'age':5}
web.update('foo', where='name = $joe',   vars=locals(),**args)
#web.update('foo', where='name = $joe',   vars=locals(),**{'name':'bob', 
'age':5})

for row in web.select('foo'):
    print row

seems do the job

in your example I would do

web.update('atab', vars=locals(), **{atn:atn1})




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to