2011-09-09 142 views
0

选择_Key_我有这个模型在谷歌的AppEngine

from google.appengine.ext import db 

class Question(db.Model): 
    Qtitle = db.StringProperty() 

Q= FirstModel(Qtitle="Who is the most handsome actor?") 
Q.put() 

然后我运行此GQL查询:

query = db.GqlQuery("SELECT __key__ FROM FirstModel Qtitle='Who is the most handsome actor?' ") 
results = query.fetch(10) 

for result in results: 
    print result 

,但得到的错误!

+0

“有错误” - 什么错误?告诉我们你的堆栈跟踪,不要让我们猜测。 –

回答

1

我看到了两个错误:

  1. 型号类别名称是Question而不是FirstModel
  2. 您错过了查询中的WHERE子句。
1
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