Dear Jake

the information goes between db() is the query. for example,
usersWithNameJake = (db.auth_user.first_name == "Jake") is a query
which you can use as db(usersWithNameJake).

the select() method takes the table field arguments to select, like db
(usersWithNameJake).select(db.auth_user.first_name,
db.auth_user.last_name).

it also allows us to limit, order and group the results like this:

db(usersWthNameJake).select(order=~db.auth_user.id,
group=db.auth_user.city, limit=(1,5))

p.s. as you noticed, you don't have to pass the field parameters to
select, by default it selects all.

p.p.s: there is no such field called city in auth_user, i just made it
up.

hope this helps.

On Dec 18, 2:57 pm, Jake <[email protected]> wrote:
> First, let me say that i'm 10 days into Python and Web2Py.  I
> apologize if this is so rudimentary as to appear stupid.
>
> So there is no DAL class.  DAL is a function, exported from the
> gluon.sql module, that returns a SQLDB object if not using GAE, so:
>
>   db = DAL('foo')
>
> makes db an instance of SQLDB.
>
> Now, lets say you do a db().select().  There is no select() method in
> the SQLDB class.  After going crazy for a couple hours, i learned what
> __call__ was, and realized that this allows you to use the select()
> method of the Set class from an instance of SQLDB.
>
> The select() method of the Set class always returns an instance of the
> Rows class, which operates like a list, so you always have to access
> the return value of the .select() method with iteration or indexes,
> even if return value is guaranteed to return one or no values (a
> lookup on an id, lets say).
>
> My question:  What information do you have to send as parameters of
> the db() call, what information do you send as parameters of
> the .select() method, and why?
>
> Thank you very much, and please correct me if i'm wrong about
> something, which is very likely.
>
> Jake

--

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