Select _Key_ in google appengine
I have this model
from google.appengine.ext import db
class Question(db.Model):
Qtitle = db.StringProperty()
Q= FirstModel(Qtitle="Who is the most handsome actor?")
Q.put()
Then I run this GQL query:
query = db.GqlQuery("SELECT __key__ FROM First开发者_如何转开发Model Qtitle='Who is the most handsome actor?' ")
results = query.fetch(10)
for result in results:
print result
But got error!
I see two errors:
- Model class name is
Question
and notFirstModel
. - You missed the
WHERE
clause in your query.
Try this , or something like that
from google.appengine.ext import db
class Question(db.Model):
Qtitle = db.StringProperty()
Q= Question(Qtitle="Who is the most handsome actor?")
Q.put()
query = db.GqlQuery('SELECT __key__ FROM Question where Qtitle = :qes' , qes='Who is the most handsome actor?').fetch(1)
for result in query
print result
精彩评论