gql

Google App Engine: Is it possible to do a Gql LIKE query?

Hi, Simple one really. In SQL, if I want to search a text field for a couple of characters, I can do: SELECT blah FROM blah WHERE blah LIKE '%text%' The documentation for App Engine makes no mention of how to achieve this, but surely it's a common enough problem? Anthony ...

Python: DISTINCT on GQuery result set (GQL, GAE)

Imagine you got an entity in the Google App Engine datastore, storing links for anonymous users. You would like to perform the following SQL query, which is not supported: SELECT DISTINCT user_hash FROM links Instead you could use: user = db.GqlQuery("SELECT user_hash FROM links") How to use Python most efficiently to filter the r...

GQL query to effectively span entity relationships

I'm in a situation where I need to span Google App Engine entity relationships in a query like in the Django database model. I'm using ListPropertys for one-to-many relationships, like so: class Foo(db.Model): bars = db.ListProperty(db.Key) class Bar(db.Model): eggs = db.ListProperty(db.Key) And I'd like to perform a query that does t...

How do you query the set of Users in Google App Domain within your Google App Engine project?

If you have a Google App Engine project you can authenticate based on either a) anyone with a google account or b) a particular google app domain. Since you can connect these two entities I would assume there is some way to query the list of users that can be authenticated. The use case is outputting a roster of all members in an organiz...

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

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 Fun...

What is a good pattern for inexact queries in the Google App Engine Datastore?

The Google App Engine Datastore querying language (gql) does not offer inexact operators like "LIKE" or even case insensitivity. One can get around the case sensitive issue by storing a lower-case version of a field. But what if I want to search for a person but I'm not sure of the spelling of the name? Is there an accepted pattern fo...

Google App Engine Query (not filter) for children of an entity

Is the parent of an entity available in a Query? Given: class Factory(db.Model): """ Parent-kind """ name = db.StringProperty() class Product(db.Model): """ Child kind, use Product(parent=factory) to make """ @property def factory(self): return self.parent() serial = db.IntegerProperty() Assume 500 fa...

How to implement internet high scores in Google App Engine

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", newUser...

What's your experience developing on Google App Engine?

Is GQL easy to learn for someone who knows SQL? How is Django/Python? Does App Engine really make scaling easy? Is there any built-in protection against "GQL Injections"? And so on... I'd love to hear the not-so-obvious ups and downs of using app engine. Cheers! ...

Google AppEngine: Date Range not returning correct results

Im trying to search for some values within a date range for a specific type, but content for dates that exist in the database are not being returned by the query. Here is an extract of the python code: deltaDays = timedelta(days= 20) endDate = datetime.date.today() startDate = endDate - deltaDays result = db.GqlQuery( "SELECT * FRO...

Does GQL support commonly available SQL Style aggregation?

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 ...

Google App Engine: Intro to their Data Store API for people with SQL Background?

Hi All, Does anyone have any good information aside from the Google App Engine docs provided by Google that gives a good overview for people with MS SQL background to porting their knowledge and using Google App Engine Data Store API effectively. For Example, if you have a self created Users Table and a Message Table Where there is a ...

Help with Google App Engine query and datetime

I use the following data: date latitude route name longitude 2009-04-11 00:50:31.640000 40.80708 White Loop 86 -77.85891 2009-04-11 00:50:27.718000 40.80708 White Loop 86 -77.85891 2009-04-11 00:50:01.562000 40.80708 White Loop 86 -77.85891 2009-04-11 00:49:48.765000 40.80708 White Loop 86 -77.85891 ...

Build a GQL query (for Google App Engine) that has a condition on ReferenceProperty

Say I have the following model: class Schedule(db.Model): tripCode = db.StringProperty(required=True) station = db.ReferenceProperty(Station, required=True) arrivalTime = db.TimeProperty(required=True) departureTime = db.TimeProperty(required=True) And let's say I have a Station object stored in the var foo. How d...

On Google App Engine, how would I look up the latest order for a customer in GQL?

If I have two tables, Customers and Orders, and I want to look up the latest order for a customer, how would I do this on Google App Engine using GQL? Normally, I would join these two tables through the foreign key, customer_id, which exists in the orders table. select orders.* from customers, orders where customers.customer_id = ord...

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

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? ...

App Engine Datastore IN Operator - how to use?

Reading: http://code.google.com/appengine/docs/python/datastore/gqlreference.html I want to use: := IN but am unsure how to make it work. Let's assume the following class User(db.Model): name = db.StringProperty() class UniqueListOfSavedItems(db.Model): str = db.StringPropery() datesaved = db.DateTimeProperty() clas...

How do I query for entities that are "nearby" with the GeoPt property in Google App Engine?

How should I create a GQL query that returns the nearest entities (from my current location) based on their GeoPt property? Should I just created a 'distance' function that calculates for a set of entities with a reasonably close distance? Thanks ahead of time! ...

How to properly do one-to-many joins on an (Python) Google App Engine datasource?

I have some models set up like: class Apps(db.Model): name = db.StringProperty(multiline=False) description = db.TextProperty() class AppScreenshots(db.Model): image_file = db.StringProperty(multiline=False) description = db.StringProperty(multiline=False) app = db.ReferenceProperty(Apps) ...

how to implement this in GQL(Google Query Language)

In MySQL it's like: select * from table1 where column1 in ('a','b','c'); how to do that in GQL? ...