how do you do a count of a result set?

John Nagle nagle at animats.com
Sat Jul 10 02:21:50 EDT 2010


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.

    It's worth noting that for many database queries, asking how many
hits there are can cost almost as much as actually retrieving them.

				John Nagle



More information about the Python-list mailing list