You do not need to generate forms for that. You can just do:
def copy_table():
for row in db((db.from.valid==1)).select(limitby=(0,1000)):
row.update(value=0) # this updates the copy (row) not the
record
db.to[0]=row # this is a shortcut for insert
On Mar 10, 12:59 pm, Jim <[email protected]> wrote:
> I'm really enjoying the power of SQLFORM.
>
> I would like to be able to use SQLFORM with two tables at once in a
> couple of different use cases:
>
> 1) I have fields in common between table1 and table2. I'm tracking
> these by hand but I'd like to control that via db.py for the app. So
> if I decide table2 needs to have field10 from table1 I don't have to
> change the code.
>
> What I'm doing now is
>
> form.vars.field1=form1.vars.field1
>
> and that's working great.
>
> 2) Google App Engine doesn't have an "alter table" command. Or if it
> does, I can't find it searching through the Google documentation and
> the Google groups for GAE.
>
> So I'd like to copy old table to new table.
>
> def copy_table():
> mfrom=db((db.from.valid==1)).select(limitby=(0,1000))
> for i,row in enumerate(mfrom):
> form1=SQLFORM(db.from)
> form=SQLFORM(db.to)
> #
> # assign values of form1 to form here ... how?
> #
> db.to.insert(**dict(form.vars))
> form1.update_record(valid=0)
>
> So this is going through the GAE table 1000 entries at a time and
> marking the moved entries as not valid.
>
> I'm trying form=form1, form=dict(form1), form.vars=form1.vars and so
> on. Studying my "Beginning Python" book and the manual and I'm still
> baffled.
>
> Thanks for any help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---