Try this:

db(db.table.id == 1).update(var = db.table.var + 1)

Marin


On Thu, Jun 6, 2013 at 9:12 AM, Robin Manoli <ramat...@gmail.com> wrote:

> I wonder about the most convenient way to increase an integer value, or
> append to a varchar. Is it possible in python to assign operators, such as:
> *db.table.var(1) += 1 # increase the value of row 1 of table with 1*
>
> Otherwise, web2py could have an increase method for integer columns, and
> append for varchar/text columns.
>
> My function to do the former, (not tested yet):
>
> *incr_table_obj_val( table_obj, column, incr=1 ):*
> *    value = getattr(table_obj, **column**)*
> *    if not **value **: **value **= 0*
> *    **value **+= int(**incr**)*
> *    table_obj.update_record(**{**column:**value**})*
>
>
> What is your best way?
>
> --
>
> ---
> 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.
>
>
>

-- 

--- 
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