gql

Is there OR operator in GQL?

一世执手 提交于 2019-12-12 13:53:25
问题 I don't know if this has been asked here. I saw couple of questions on "like" operator but I'm not sure if that's I'm looking for. Sorry I'm a noob at this. But I am moving from MySQL to Google App Engine and was wondering if there was an OR operator in GQL similar to ones in MySQL. Basically what I am trying to achieve is get the login on name via their username or email address. So my query would be something like this. query = db.GqlQuery("SELECT * FROM mytable where username = :name OR

one-to-many GQL query and putting results into a dictionary

喜欢而已 提交于 2019-12-12 03:16:09
问题 I have a google database called Main . class Main(db.Model): name = db.StringProperty() phone = db.StringProperty() There's another database Photo which references Main through a one-to-many relationship. class Photo(db.Model): main = db.ReferenceProperty(Main,collection_name='photos') photo1 = db.StringProperty() photo2 = db.StringProperty() I was wondering if anyone knows how to make a dictionary, based on the query of Main (example shown below): class Name(webapp.RequestHandler): def get

what is the GQL count query

落爺英雄遲暮 提交于 2019-12-11 16:42:18
问题 In the interest of time, I do mean GQL, as in SELECT * FROM Song WHERE composer = 'Lennon, John' The following failed SELECT COUNT(*) FROM myEntity also the following SELECT COUNT() FROM myEntity 回答1: As shown here, there is actually a way to count the return of your GQL. The doc about the GQL language shows you can't really do a count on the query itself. So what you would do is take your select *, put it in a GQL query object, then call the "count()" method on that object to have the count

GAE sql (GQL) correct format?

折月煮酒 提交于 2019-12-11 06:46:18
问题 My sql looks like this : SELECT * FROM Contact_Info_Entry where Name.length < 18 [ Got incorrect GQL syntax error message ] "Name" is a String in the Contact_Info_Entry.java class, I'm not familiar with sql, let alone GQL, if I want to select all names less than 18 characters long, what's the correct GQL syntax to use ? 回答1: You can't filter by a field's length with GQL. However, you could achieve this if you denormalize your model and include the length of Name as a field in your model. 回答2:

App Engine GQL Query - Sorting

北战南征 提交于 2019-12-11 06:22:22
问题 Having some issues with merging two GQLQueries in GAE (python). fp_events = db.GqlQuery("SELECT * FROM Event WHERE firstPlayer=:1", alias).fetch(mylimit) sp_events = db.GqlQuery("SELECT * FROM Event WHERE secondPlayer=:1", alias).fetch(mylimit) events = fp_events.append(sp_events) However, when I try to iterate through these events using the for loop for event in events: , I get a TypeError: 'NoneType' object is not iterable error at that line. I suspect that this has something to do with the

GQL: Find all entities that contain a substring

蓝咒 提交于 2019-12-11 00:05:37
问题 I have some entities that have a StringProperty and I would like to query for all the entities that match a substring. Is there a way to do that using just GQL? For example, if my datastore looks like this: ID/Name question_text -------------------------------------------------------------- 3001 I like to eat chicken. 3020 I only like to eat chicken that is deep fried. 3045 I like filet mignon. 3052 I like cheese. What would the GQL query be to find all the entities that contain 'chicken' in

how to understand “cursor” correctly

心不动则不痛 提交于 2019-12-10 18:31:47
问题 I'm trying to apply cursor to my app, however, the document is not clear enough for me. Google's description for cursor http://code.google.com/appengine/docs/python/datastore/queries.html#Query_Cursors The cursor's position is defined as the location in the result list after the last result returned. A cursor is not a relative position in the list (it's not an offset); it's a marker to which the datastore can jump when starting an index scan for results. If the results for a query change

How to insert a record using the Admin console Datastore Viewer using GQL

穿精又带淫゛_ 提交于 2019-12-10 14:38:29
问题 Is it possible to INSERT or UPDATE a entity in the datastore using the Admin > Datastore Viewer. E.g. executing something like INSERT INTO table VALUES (Foo='Bar') 回答1: No you can't; GQL is a SQL-like language just for retrieving entities or keys. You can INSERT, UPDATE or DELETE entities using the Datastore Viewer or from your application code. 回答2: Not with GQL, but it is possible to INSERT and UPDATE entities with the Datastore Viewer . To INSERT : After clicking on the Datastore Viewer ,

App Engine Datastore Viewer, how to show count of records using GQL?

大城市里の小女人 提交于 2019-12-10 00:40:34
问题 I would think this would be easy for an SQL-alike! What I want is the GQL equivalent of: select count(*) from foo; and to get back an answer something similar to: 1972 records. And I want to do this in GQL from the "command line" in the web-based DataStore viewer. (You know, the one that shows 20 at a time and lets me see "next 20") Anyway -- I'm sure it's brain-dead easy, I just can't seem to find the correct syntax. Any help would be appreciated. Thanks! 回答1: As it's stated in other

How to find entries which has not empty StringListProperty?

自古美人都是妖i 提交于 2019-12-08 18:51:51
问题 I have a following model in the Google appengine app. class TestModel(db.Model): names = db.StringListProperty(required=False) So, I want to get entries which has not empty in names property. I tried like this. TestModel.all().filter('names !=', []) But it raises the exception: BadValueError: Filtering on lists is not supported How can I filter it? or Should I check one by one like following? for entry in TestModel.all(): if len(entry.names) > 0: result.append(entry) 回答1: Try this: TestModel