gql

GQL query help - How can I write a query with where clause in GQL ? I am using google appengine datastore

这一生的挚爱 提交于 2020-01-24 12:02:11
问题 I have three records in a table example: *Usernames* *email* *city* Nick nick@example.com London Vikky vicky@example.com Paris Lisa lisa@example.com Sydney Now I want to get specific record keeping email ID as a key , SQL query may be like this select * from table1 where email = "vicky@example.com" What is the equivalent GQL query for the above ?? 回答1: SELECT * FROM table1 WHERE email = 'vicky@example.com' should work fine in GQL. See here for more information http://code.google.com/appengine

GQL query help - How can I write a query with where clause in GQL ? I am using google appengine datastore

回眸只為那壹抹淺笑 提交于 2020-01-24 12:02:09
问题 I have three records in a table example: *Usernames* *email* *city* Nick nick@example.com London Vikky vicky@example.com Paris Lisa lisa@example.com Sydney Now I want to get specific record keeping email ID as a key , SQL query may be like this select * from table1 where email = "vicky@example.com" What is the equivalent GQL query for the above ?? 回答1: SELECT * FROM table1 WHERE email = 'vicky@example.com' should work fine in GQL. See here for more information http://code.google.com/appengine

In a GQL query what ANCESTOR IS :1 exactly means?

大城市里の小女人 提交于 2020-01-06 08:48:33
问题 I have come across with GQL queries containing ANCESTOR IS :1. So, what the ancestor is and what :1 stands for? query = db.GqlQuery("SELECT * " "FROM my_db " "WHERE ANCESTOR IS :1 AND answer > :3 AND ch = :4 " "ORDER BY answer", my_db_key('name'), x, ch) e.g in the query above what this line "WHERE ANCESTOR IS :1 AND answer > :3 AND ch = :4 " is suppose to do? 回答1: An ancestor query returns descendants of the given ancestor entity; that is, entities that list the ancestor as their parent, or

Google App Engine null sort order

女生的网名这么多〃 提交于 2020-01-06 05:41:19
问题 According to Googles Documentation, null values have no sort order. Is there any way to configure this behavior. For instance, if I am sorting an integer property in ascending order, can I configure the datastore to return null values last or first? 回答1: Your best bet may be to save the property as a blank "" string for each entity that has a null value for that property. Be sure to run put() on each entity that you alter. employees = Employee.all().fetch(50) for employee in employees: if

Getting The Most Recent Data Item - Google App Engine - Python

筅森魡賤 提交于 2020-01-04 05:36:14
问题 I need to retrieve the most recent item added to a collection. Here is how I'm doing it: class Box(db.Model): ID = db.IntegerProperty() class Item(db.Model): box = db.ReferenceProperty(Action, collection_name='items') date = db.DateTimeProperty(auto_now_add=True) #get most recent item lastItem = box.items.order('-date')[0] Is this an expensive way to do it? Is there a better way? 回答1: If you are going to iterate over a list of boxes, that is a very bad way to do it. You will run an additional

What's your experience developing on Google App Engine?

故事扮演 提交于 2020-01-01 09:27:25
问题 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! 回答1: The most glaring and frustrating issue is the datastore api, which looks great and is very well thought out and easy to work with if you are used to SQL, but has a 1000 row limit across all query resultsets, and you can't access

How to construct GQL to not contain a value from a set?

老子叫甜甜 提交于 2019-12-31 01:45:32
问题 Is it possible to select from a google app engine db where the key of a db.Model object is not in a given list? If so, what would be the syntax? Ex of a model class: class Spam(db.Model): field1 = db.BooleanProperty(default=false) field2 = db.IntegerProperty() Example of a query which I'd like to work but can't figure out: spam_results = db.GqlQuery( "SELECT * FROM Spam WHERE key NOT IN :1 LIMIT 10", ['ag1waWNreXByZXNlbnRzchMLEgxBbm5vdW5jZW1lbnQYjAEM',

Does GQL support commonly available SQL Style aggregation?

南笙酒味 提交于 2019-12-30 04:59:04
问题 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 回答1: 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

GQL error on WHERE

隐身守侯 提交于 2019-12-24 21:36:50
问题 select from comments.Comment where ownerType == 'looks.Look' AND ownerName == 'Yakuza' order by date I get exception: Portion of expression could not be parsed: AND ownerName == 'Yakuza' While this query works nice: select from comments.Comment where ownerType == 'looks.Look' order by date And this too: select from comments.Comment where ownerName == 'Yakuza' order by date The full code: PersistenceManager pm = PMF.get().getPersistenceManager(); String query = "... query goes here ..."; List

GQL with two tables

本小妞迷上赌 提交于 2019-12-24 21:17:13
问题 Hello i am doing a very small application in google appengine and i use python. My problem is that i have two tables using de db.model ("clients" and "requests"). The table "client" has got the email and name fields and the table "requests" has got the email and issue fields. I want to do a query that returns for each request the email, issue and client name, if the email is the same in the two tables. Can anyone help, please? 回答1: The app engine datastore does not support joins, so you will