but (I think) he wants something working on GAE.
On Sep 10, 11:55 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > I thought I answered this > > random_record = db().select(db.mytable.ALL,orderby='<random>,limitby= > (0,1))[0] > > On Sep 9, 8:27 pm, Iceberg <iceb...@21cn.com> wrote: > > > On Sep9, 8:07pm, Richard <richar...@gmail.com> wrote: > > > > hi, > > > > is there an efficient way to get a random record from a table? > > > An obvious non-efficient way would be to get all the records and do > > > random.choice(). > > > > thanks, > > > Richard > > > Would like to see comments on this. > > > import random > > total_count = db(db.mytable.id>1).count() # well, this is one extra > > db query > > random_id = random.randint(1, total_count) > > random_record = db.mytable[random_id] # Does this work on GAE? > > > Iceberg > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---