views:

105

answers:

2

Are they just different interfaces to the same underlying query?

+1  A: 

[snippet from http://code.google.com/appengine/docs/python/datastore/gqlqueryclass.html] As with the Query class, the application executes the query and accesses results either by calling the fetch() method, or by treating the GqlQuery object as an iterable. See the Query documentation for more information.

There is one difference between how Query and GqlQuery access results: If the GQL query includes a LIMIT clause or an OFFSET clause, results are retrieved as with the equivalent fetch() method, even if the iterator interface is used to access the results. When a GqlQuery whose GQL contains LIMIT or OFFSET is used as an iterable, one call is made to the datastore to fetch all of the results, and the iterator returns each of the results from memory.

Priyank
A: 

Practically speaking I think they added the GQL method just so people coming from an SQL background would be a little bit more comfortable. I like using Queries or the .all() method because you can split filters onto multiple lines pretty easily:

messages = (MyModel.all()
                   .filter("prop1 = ", 123)
                   .filter("prop2 = ", 456)
                   .fetch(10))
Brandon Thomson