Sorry if I'm misunderstanding, but it sounds like you want to retrieve a group of entities from the datastore and sum their respective float_value
properties. If that is what you want to do, you will need to set up a query that pulls all of the entities in question (here we will just use Sum_DB.all()
to pull all of them) and then iterate through the returned list of objects, summing their float_value
property. For example:
class Sum_DB(db.Model):
name_of_profile = db.StringProperty(required = True)
float_value= db.FloatProperty()
class MainHandler(webapp2.RequestHandler):
def get(self, *args, **kwargs):
r = Sum_DB(name_of_profile='test1', float_value=float(1.2359))
s = Sum_DB(name_of_profile='test2', float_value=float(2.2355))
t = Sum_DB(name_of_profile='test3', float_value=float(4.2185))
r.put()
s.put()
t.put()
# Using the Query class
query = Sum_DB.all()
# You can now iterate over that 'query', with each element
# representing an entity from your datastore. Each entity
# will have the properties you defined in Sum_DB, so you
# can access them by name.
sum_me_up = sum(result.float_value for result in query)
# Or using GQL - the concept/result is the same
query2 = db.GqlQuery('SELECT * from Sum_DB')
sum_me_up2 = sum(result.float_value for result in query2)
self.response.out.write('Query: {0} | GQL: {1}'.format(sum_me_up,
sum_me_up2))
app = webapp2.WSGIApplication([
('/', MainHandler),
],
debug=True)