Hi Joost,
You can do something like this:

import sqlobject
from sqlobject.sqlbuilder import *

conn = model.Searches._connection
query = Select( [model.Searches.q.keyword,
                             func.Count(model.Searches.q.keyword)],
                             groupBy=model.Searches.q.keyword,
                              orderBy=model.Searches.q.keyword )
query = conn.queryAll(conn.sqlrepr(query))

This will return an array of tuples.
The best reference arround for this kind of queries is a post by Ben  
Bangert:
http://groovie.org/articles/2005/11/01/how-to-use-database-agnostic- 
sql-in-sqlobject

Cheers.
Ronald

On Feb 26, 2006, at 5:44 PM, Joost Moesker wrote:

>
> Does anyone know if its possible to use SQLObject/ SQLBuilder to build
> queries like:
>
>   SELECT d.keyword, count(d.keyword) c FROM db.searches
>   GROUP BY d.keyword
>   ORDER BY c DESC;
>
> The result of such a query arent SQLObject instances them self. Yet it
> is quite common to have such queries as properties. It would be really
> nice to do this in db agnostic manner using SQLObject.
>
>
>

________________________________
Ronald Jaramillo
mail: ronald AT checkandshare DOT com
blog: http://www.checkandshare.com/blog




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to