words= db(db.phmap.id>0).select(limitby=(0,5),order='<random>')
table =SQLTABLE(words,
   headers={'phmap.F1':db.phmap.F1.label,phmap.F2:db.phmap.F2.label'},
   columns=['phmap.F1',phmap.F2'],
   truncate=32)



On Aug 13, 2:02 am, dlin <dlin...@gmail.com> wrote:
> I've a table with fields
> Field('F1', label='name')
> Field('F2', label='data')
> ....
> Field('F20', label='xxx')
>
> I wish use crud to display 5 random  rows of the table, and only
> display F1, F2.
>
> So, here is my  code:
>
> ids = [x.values()[0] for x in db().select(db.phmap.id).as_list()]
> idr = random.sample(ids, 5)
> words  = db(db.phmap.id.belongs(idr)).select(db.phmap.ALL)
>
> I want to display the words with only F1 and F2 fields.
> How could I display them by crud.select()?
> I want to be smarter to use the already defined labels in db.py,  but
> I don't know how to do it.

Reply via email to