I use Anthony's method because it returns a true list. as_list() returns a list of dictionaries, and you still have to iterate over the dictionaries in the list to extract the values.
On Friday, August 10, 2012 4:34:01 PM UTC-4, Toby Shepard wrote: > > > I'm in a situation where I just want a single column back from > a table. I'd like it as a list so I could just pass it on > to the next function. > > All I can think of is something like: > > temp = [] > > for thing in db(db.mytable).select(db.mytable.myfield): > temp.append(thing) > > return temp > > I was hoping for something like: > > return db(db.mytable).select(db.mytable.myfield).as_list() > > Or something like that. > > As an aside, I have a python dbi that has four central ways to get > data back. I call them: > > atom() scalar as in 'select first from person where > id = 1' > row() dict as in 'select * from person' where id > = 1' > column() list as in 'select first from person' > world() list of dict: 'select * from person' > > They end up being uite convenient and result in concise syntax. > > Thanks, > > Tobiah > --