开发者

Google app engine: Queries

开发者 https://www.devze.com 2023-03-20 19:04 出处:网络
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.

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. 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. What am I doing wrong? Thanks for you开发者_如何学Pythonr help!


Read the doc. You can't query with a raw ID, you need to create a Key object.


get_by_id

is what I was looking for!

0

精彩评论

暂无评论...
验证码 换一张
取 消