list() loads the complete result set into the memory in order to convert it into a list, which might fill it up and could take a long time. You can probably avoid that by using something like:
user_data = web.ctx.db.select(...) #your query first = next(iter(user_data), None) print(first) iter(user_data) produces an iterator over the result set, next() then fetches the next (in this case the first) element of it. If the result set should be empty, None would be returned. Am 25.07.2013 um 23:47 schrieb Claudio Dusan Vega Ozuljevich: > Thanks, man. That actually did the trick. One thing though... Why is > it dangerous? > > On Thu, Jul 25, 2013 at 5:12 PM, Dragan Espenschied <[email protected]> wrote: >> user_data = web.ctx.db.select('role', >> what="id, name, email, >> administrative_division", >> where="email=$user_input_email", >> vars={"user_input_email":user_input.email} >> ).list() >> >> print user_data[0].name >> >> >> >> >> Use the "list" method on your database query to load the complete result into >> memory as a python list. Can be dangerous with queries that return a lot of >> results. >> >> >> >> >> >> Am 25.07.2013 16:56, schrieb Claudio Dusan Vega Ozuljevich: >>> Hi guys. >>> >>> I got this statement >>> >>> user_data = web.ctx.db.select('role', >>> what="id, name, email, >>> administrative_division", >>> where="email=$user_input_email", >>> >>> vars={"user_input_email":user_input.email} >>> ) >>> >>> now my question is, if I want to access just the name, how do I do it? >>> >>> I'm using the following statement, but I think is a wrong way to do it. >>> >>> for data in user_data: >>> print data.name >>> >>> is there a way to access the parameter name or any other without using >>> the for in. >>> >>> Thanks in advance! >>> >> >> -- >> http://1x-upon.com/~despens/ >NEW!< >> http://noobz.cc/ >> http://contemporary-home-computing.org/1tb/ >> >> -- >> You received this message because you are subscribed to the Google Groups >> "web.py" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/webpy. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "web.py" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/webpy. > For more options, visit https://groups.google.com/groups/opt_out. > > -- Ole Trenner <[email protected]> -- You received this message because you are subscribed to the Google Groups "web.py" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/webpy. For more options, visit https://groups.google.com/groups/opt_out.
