Thanks for the comments. I read Chapter 6 which is where I got the bit of code to access the records.
I can ensure that there is records with those id's. Its a script that grabs data off from the internet and inserts that data into that table. Then I grab the last 5 records including the one it is grabbing to do a calculation on it. It is not too clear in the book how I should be getting a record by the id is what I think my problem is. Thanks, Tom On Tuesday, May 20, 2014 4:53:13 AM UTC-4, Johann Spies wrote: > > On 19 May 2014 22:06, Tom Russell <tsrda...@gmail.com <javascript:>>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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.