在 Google AppEngine 中选择_Key_

发布于 2024-12-04 03:14:16 字数 427 浏览 1 评论 0原文

我有这个模型

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

但出现错误!

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 FirstModel Qtitle='Who is the most handsome actor?' ")
results = query.fetch(10)

for result in results:
   print result

But got error!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终难愈 2024-12-11 03:14:16

我看到两个错误:

  1. 模型类名称是 Question 而不是 FirstModel
  2. 您错过了查询中的 WHERE 子句。

I see two errors:

  1. Model class name is Question and not FirstModel.
  2. You missed the WHERE clause in your query.
叫思念不要吵 2024-12-11 03:14:16
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
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文