简体   繁体   English

Google 应用引擎:查询

[英]Google app engine: Queries

I have a table Foo where my foos are stored and if I log in via browser and list all my foos there is one Foo with ID=12.我有一张 Foo 表,其中存储了我的 foo,如果我通过浏览器登录并列出所有我的 foo,则有一个 ID=12 的 Foo。 Then I have this code:然后我有这个代码:

logging.info(fid)
q = db.GqlQuery("SELECT * FROM Foo WHERE ID = :1", fid)
logging.info(list(q))

which prints哪个打印

12
[]

If I do q.fetch(4) it still gives me index out of range.如果我做q.fetch(4)它仍然让我的索引超出范围。 What am I doing wrong?我究竟做错了什么? Thanks for your help!谢谢你的帮助!

Read the doc .阅读文档 You can't query with a raw ID, you need to create a Key object.不能用原始ID查询,需要创建Key object。

get_by_id

is what I was looking for!就是我要找的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM