gqlquery

Does GQL support commonly available SQL Style aggregation?

蓝咒 提交于 2019-11-30 14:07:40
What I'm looking for a simple Aggregate Functions that are widely available in versions of SQL. Simple things like Select Count(*) from table1 to the more complex. If these are available, is there some documentation you could point me to? Thanks - Giggy The SQL aggregate functions are not available. What you want to do is follow patterns like the sharded counters example: http://code.google.com/appengine/articles/sharding_counters.html which explain that instead of aggregating the values on queries, you want to keep the counters up to date when the values are inserted, updated, or deleted. The

How to implement internet high scores in Google App Engine

≡放荡痞女 提交于 2019-11-30 11:09:23
问题 I want to implement internet high scores for my game. And give feedback to players which place they have (not only top100 or something like that). In normal SQL it would look like that: SELECT COUNT(*) FROM Scores WHERE points > :newUsersPoints and GQL have something similar db.GqlQuery("SELECT * FROM Score WHERE points > :1", newUsersPoints).count() but since count() is limited only to 1000 it won't be very useful in my case. Do you have any ideas on how to implement this? I have two First:

How to query all entries from past 6 hours ( datetime) in GQL?

余生长醉 提交于 2019-11-28 08:26:57
I have a simple table in Google App Engine with a date field. I want to query all the rows with the date field valued between now and 6 hours ago. How do I form this query? SELECT * FROM simpletable WHERE datefield < DATETIME(year, month, day, hour, minute, second) computing those year, month, &c, in your application code. I know you say GQL, but here's a python helper function I use: import datetime def seconds_ago(time_s): return datetime.datetime.now() - datetime.timedelta(seconds=time_s) There may well be a more concise way to write it: I'm not a python expert and went with the first thing

What's the best way to count results in GQL?

混江龙づ霸主 提交于 2019-11-27 11:35:02
I figure one way to do a count is like this: foo = db.GqlQuery("SELECT * FROM bar WHERE baz = 'baz') my_count = foo.count() What I don't like is my count will be limited to 1000 max and my query will probably be slow. Anyone out there with a workaround? I have one in mind, but it doesn't feel clean. If only GQL had a real COUNT Function... +1 to Jehiah's response. Official and blessed method on getting object counters on GAE is to build sharded counter . Despite heavily sounding name, this is pretty straightforward. You have to flip your thinking when working with a scalable datastore like GAE

How to query all entries from past 6 hours ( datetime) in GQL?

此生再无相见时 提交于 2019-11-27 02:12:51
问题 I have a simple table in Google App Engine with a date field. I want to query all the rows with the date field valued between now and 6 hours ago. How do I form this query? 回答1: SELECT * FROM simpletable WHERE datefield < DATETIME(year, month, day, hour, minute, second) computing those year, month, &c, in your application code. 回答2: I know you say GQL, but here's a python helper function I use: import datetime def seconds_ago(time_s): return datetime.datetime.now() - datetime.timedelta

What&#39;s the best way to count results in GQL?

对着背影说爱祢 提交于 2019-11-26 15:37:54
问题 I figure one way to do a count is like this: foo = db.GqlQuery("SELECT * FROM bar WHERE baz = 'baz') my_count = foo.count() What I don't like is my count will be limited to 1000 max and my query will probably be slow. Anyone out there with a workaround? I have one in mind, but it doesn't feel clean. If only GQL had a real COUNT Function... 回答1: +1 to Jehiah's response. Official and blessed method on getting object counters on GAE is to build sharded counter. Despite heavily sounding name,