how do you do a count of a result set?
Brian Quinlan
brian at sweetapp.com
Sat Jul 10 02:53:27 EDT 2010
On 10 Jul 2010, at 16:21, John Nagle wrote:
> On 7/9/2010 11:08 PM, Dennis Lee Bieber wrote:
>> On Sat, 10 Jul 2010 06:56:13 +0200, Rene Veerman<rene7705 at gmail.com>
>> declaimed the following in gmane.comp.python.general:
>>
>>> hi.
>>>
>>> i'm using this function;
>>>
>>>
>>> def dbCacheGet(self, appParams):
>>> results = db.GqlQuery(
>>> "SELECT * "
>>> "FROM DBcache "
>>> "WHERE url='"+appParams['urlCalled']+"'"
>>> ).fetch(1)
>>> if results.count('*')==0:
>>> return None
>>> else:
>>> return results
>>>
>>>
>>> i dont think this will work correctly.
>>> i need a function that returns the complete count in the results
>>> variable.
>
> This is really a Google AppEngine question. Ask in their support
> forums.
http://groups.google.com/group/google-appengine-python would be a good
place to start.
> It's worth noting that for many database queries, asking how many
> hits there are can cost almost as much as actually retrieving them.
That is the case with the App Engine datastore. If your counts contain
more than a few hundred results then you would be better so store them
somewhere.
Cheers,
Brian
More information about the Python-list
mailing list