如何按创建日期查询Google App Engine Blobstore并对结果进行排序
我需要从 GAE blobstore 检索最新的文件集。目前我的代码表示,
nDays = 10 #this is set at run time
gqlQuery = blobstore.BlobInfo.gql("WHERE filename = :1 ORDER BY creation DESC",<filename>)
cursor = gqlQuery.fetch(nDays)
当我通过调用cursor[i].creation 迭代并打印数据时,它不会给我从今天开始的最后nDays。例如,今天是 8 月 20 日。我希望它能为我提供 8 月 11 日至 8 月 20 日的数据(我每天都有一个文件)。相反,它给了我几天前 8 月 13 日的数据。
如果我删除 gqlquery 中的 ORDER BY,它会正确返回所有结果(未排序)。 如果我使 gqlQuery 可迭代,这样我
for filename in gqlQuery:
print filename.creation
就只会打印从 8 月 13 日到几天(大约 8 天)的内容。我知道直到今天为止还有数据。从GAE中,我可以查看数据。此外,当文件上传到 blobstore 时,Google 会自动标记创建日期。
有人知道我错过了什么吗?
I need to retrieve the latest set of files from GAE blobstore. Currently my code says
nDays = 10 #this is set at run time
gqlQuery = blobstore.BlobInfo.gql("WHERE filename = :1 ORDER BY creation DESC",<filename>)
cursor = gqlQuery.fetch(nDays)
when I iterate and print out the data by calling cursor[i].creation, it doesn't give me the last nDays starting from today. For example, today is August 20. I expect it to give me data from Aug 11 - Aug 20 (I have a file for each day). Instead it gives me data from Aug 13 back a few days.
If i remove the ORDER BY in the gqlquery, it correctly returns all the results (not sorted).
If I make the gqlQuery iterable so that I say something like
for filename in gqlQuery:
print filename.creation
it only prints from August 13 back to a few days (about 8 days). I know for a fact there is data up till today. From GAE, I can view the data. Also, the creation date is stamped automatically by Google when the file is uploaded to blobstore.
Anyone know what I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也可能会错过一些东西,但是您查询中“filename = :1”的目的是什么?
这对我的 blobstore 正确运行:
Florent
I may also miss something, but what's the purpose of "filename = :1" in you query?
This ran correctly against my blobstore:
Florent