On 19 May 2014 22:06, Tom Russell <[email protected]> wrote:

I have some records in my db that I need to access to get them and perform
> some calculations on.
>
> My code to access the records is:
>
>  rows = db(db.voltrin.id > 0).count()
>

 Let us assume rows = 100 at this point.

>
>  currentrow = rows - 4
>

currentrow = 96


>
>     for x in range(currentrow, rows):
>
       range(96, 100)

>         record = db.voltrin(db.voltrin.id==x)
>
                record = db.voltrin(db.voltrin.id =
96).select(whateverfieldsyouwantoworkwith)



> Is this the right way to access the record at a given id?
>
> No.

I would suggest you read Chapter 6 in the web2py book (
http://web2py.com/book).

Just a comment about your code: there is no way you can ensure in the above
example that there will be an id==96 in that database.

Regards
Johann
 --
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to