python – 与谷歌应用程序引擎分页
发布时间:2020-12-20 13:23:26 所属栏目:Python 来源:网络整理
导读:我有几个关于如何与gae进行分页的问题.测试代码: for i in range(0,6): MyClass(myProperty=unicode(i)).put() q = MyClass.all() cursor = None print haveMore = True batchSize = 2 i = 1 while haveMore: print 'Batch',i i = i + 1 result_set = q.wit
我有几个关于如何与gae进行分页的问题.测试代码:
for i in range(0,6): MyClass(myProperty=unicode(i)).put() q = MyClass.all() cursor = None print haveMore = True batchSize = 2 i = 1 while haveMore: print 'Batch',i i = i + 1 result_set = q.with_cursor(start_cursor=cursor).fetch(batchSize) for obj in result_set: print obj.myProperty cursor = q.cursor() print cursor haveMore = True if len(result_set) == batchSize else False 输出: Batch 1 0 1 E9oBTgoMdGVzdGJlZC10ZXN0GgdNeUNsYXNzIUNVUlNPUiFqHWoMdGVzdGJlZC10ZXN0cg0LEgdNeUNsYXNzGAIMggENCxIHTXlDbGFzcxgCDOABABQ= Batch 2 2 3 E9oBTgoMdGVzdGJlZC10ZXN0GgdNeUNsYXNzIUNVUlNPUiFqHWoMdGVzdGJlZC10ZXN0cg0LEgdNeUNsYXNzGAQMggENCxIHTXlDbGFzcxgEDOABABQ= Batch 3 4 5 E9oBTgoMdGVzdGJlZC10ZXN0GgdNeUNsYXNzIUNVUlNPUiFqHWoMdGVzdGJlZC10ZXN0cg0LEgdNeUNsYXNzGAYMggENCxIHTXlDbGFzcxgGDOABABQ= Batch 4 问题: >首先,当在for循环的不同迭代中使用相同的游标时,结果集如何推进? 解决方法
看看这里
Query with paging by cursor causes error because of limitations for “IN filter” in cursor() method… What should be the alternative?
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |