What do you mean it won't run? Do you get an error, or just don't see the 
changes you expect? Are the values in question in the database actually 
None (i.e., NULL), or are they empty strings ('')?

If you're trying to change all the records in the table, would be easier to 
do:

for field in ['name', 'address']:
    db(db.mytable[field] == None).update(**{field: 'Not Specified'})

That will just issue two updates rather selecting the entire table and then 
doing two updates per row.

Also, if you have a Rows object and need to make multiple changes to a 
given Row, you can do:

row.update(...)
row.update(...)
row.update_record()

The row.update() calls make changes to the Row object itself (but not the 
database). Then, .update_record() updates the database with whatever 
changes have been made to the Row.

Anthony

On Tuesday, January 21, 2014 11:00:10 AM UTC-5, Mark Billion wrote:
>
>   I cannot seem to get this code to run, even though Im almost sure Im 
> right.....any thoughts would be appreciated!
>
> for r in rows:
>
>       . . . . . 
>
>       for k, v in {'name': r.name, 'address': r.address . . .  }.items():
>           if v is None:
>             db(db.client.id==r.id).update(**{k:'Not Specified'})
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to