On Sat, Aug 1, 2009 at 1:49 PM, Pynthon <[email protected]> wrote:

>
> I think that I know what you mean. And well it's 3 month's ago when I
> played with Python. You mean this
>
> http://pastebin.com/m59ff6f6f
>
> Because you want return that data your need to put the [0] after is
> because you only want to see the web2py info? So yes: why you don't
> need to use this is normal select queries :P?


this depends on what you want, and the context.


>
>
> Thanks!
>
> On 1 aug, 20:33, Yarko Tymciurak <[email protected]> wrote:
> > On Sat, Aug 1, 2009 at 1:22 PM, Pynthon <[email protected]> wrote:
> >
> > > You mean otherwise it gets the whole dict? and now only id: 1 ?
> >
> > I mean select returns a list:   [ ]
> >
> > or a list of rows (with only the columns from the table you requested -
> > some, or ALL):  [ { ..}, {...}, ...]
> > result[0]  is   [ {first_row_returned}, {second_row_returned}, ...][0]
> > which is just the first item in the list - {first_row_returned}
> >
> > You are familiar with the Python notation for lists: []   and
> dictionaries:
> > {},  no?
> >
> >
> >
> > > On 1 aug, 19:48, Yarko Tymciurak <[email protected]> wrote:
> > > > On Sat, Aug 1, 2009 at 12:43 PM, Yarko Tymciurak <[email protected]>
> > > wrote:
> >
> > > > > On Sat, Aug 1, 2009 at 10:41 AM, Pynthon <[email protected]>
> wrote:
> >
> > > > >> 1. =] Nice! But watch this query:
> >
> > > > >> db( db.leden.info == 'Hans' ).select( db.leden.id, db.leden.naam
> )
> >
> > > > >> It still give me no error so if I enter a where clause the DAL
> will
> > > > >> get all the fields?
> >
> > > > >> 2. You mean if you don't use [0] this will be the output
> >
> > > > >> output = [1, 'name', 'info'] And to get it nice you need to use
> [0]?
> >
> > > > > Here's the way to think of this:
> >
> > > > > each select from web2py returns a dictionary which represents the
> rows
> > > > > selected - a LIST OF ROWS:
> >
> > > > ...sorry... this should have said "...returns a list of
> dictionaries..."
> >
> > > > > query_results = [ retuned_row1, returned_row2, returned_row3, ... ]
> >
> > > > > What is returned for each result query is a dict (not a list);
> > > > > In your example:
> >
> > > > > output = [ {id:1, naam:'name', info:'Hans'} ]
> >
> > > > > db( yourQuery ).select()[0]  is just the first (in your example,
> only)
> > > row,
> > > > > so just the dict (not in a list):
> > > > >  {id:1, naam:'name', info:'Hans'}
> >
> > > > > If you had multiple results, you would have:
> >
> > > > > output = [ {id:1, naam:'name', info:'Hans'},
> > > > >            {id:2, naam:'Hans', info:'This is a correction'},
> > > > >          ...]
> >
> > > > > Does this make more sense?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to