如何按创建日期查询Google App Engine Blobstore并对结果进行排序

发布于 2024-11-30 18:04:11 字数 659 浏览 0 评论 0原文

我需要从 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 技术交流群。

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

发布评论

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

评论(1

南风几经秋 2024-12-07 18:04:11

我也可能会错过一些东西,但是您查询中“filename = :1”的目的是什么?

这对我的 blobstore 正确运行:

gqlQuery = blobstore.BlobInfo.gql("ORDER BY creation DESC")
blobs = gqlQuery.fetch(5)
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write("Lasts blobs<br>")
for blob in blobs:
    self.response.out.write(blob.filename + "<br>")

Florent

I may also miss something, but what's the purpose of "filename = :1" in you query?

This ran correctly against my blobstore:

gqlQuery = blobstore.BlobInfo.gql("ORDER BY creation DESC")
blobs = gqlQuery.fetch(5)
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write("Lasts blobs<br>")
for blob in blobs:
    self.response.out.write(blob.filename + "<br>")

Florent

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文