On Wednesday, March 26, 2014 12:58:36 PM UTC-7, Niphlod wrote:
>
> assuming.....
>
> count = db.table.id.count()
> groupby = db.table.birthday.month()
>
> #you can do
>
> rows = db(db.table.id >0).select(count, groupby, groupby=groupby)
> for row in rows:
>     print row[count], row[groupby]
>
>
>
> i.e. the variables (count, groupby) you set are automatically "translated" 
> to the "ugly format" you're referring to. 
>

Okay, that looks good.
 

> This is the only recommended way to deal with those, because the 
> row['_extra']["web2py_extract('month',person.birthdate)"]
>
> is only valid for a specific adapter (in this case, sqlite). This means 
> that if you switch to mysql, it won't work.
>
>
That doesn't surprise me; if it wasn't that, it would be "subject to change 
without notice" (invoking its privilege as an implementation detail).
 

> BEWARE(closely related): in a groupby query you can only retrieve the 
> groupby field(s) and any other column MUST be an aggregate (i.e. count(), 
> sum(), etc etc)
>
>
Good to know, and good to have reinforced!

Thanks.

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to