App Engine下载有限数量的实体

时间:2012-01-02 05:54:20

标签: google-app-engine

我想下载有限数量的应用引擎实体,比如说只有500个。是否可以通过Python bulkloader API执行此操作?

2 个答案:

答案 0 :(得分:0)

AFAIK bulkloader API旨在获取给定种类的所有实体或所有实体。

如果要下载500个特定实体,可以依赖远程API远程访问数据存储区,如this article

中所述

答案 1 :(得分:0)

在不下载所有实体的情况下调试转换失败非常有用。这是我对bulkloader的修改,基于1.6.4 SDK:

diff -r 1/google/appengine/tools/appcfg.py 2/google/appengine/tools/appcfg.py
3562a3563
>                      'limit',
3667a3669,3671
>     parser.add_option('--limit', type='int', dest='limit',
>                       action='store', default=None,
>                       help='Number of records to download (for debugging).')
diff -r 1/google/appengine/tools/bulkloader.py 2/google/appengine/tools/bulkloader.py
1252c1252,1253
                throttle_class=None,
>                limit=None):
1285a1287,1289
>     if limit != None:
>         logger.info("Aborting download after downloading %s entities" % limit)
>     self.limit_cnt = limit
1424a1429,1432
>       if self.limit_cnt and self.limit_cnt <= 0:
>         logger.info("Reached limit, abort downloading more entities")
>         return []
>
1429a1438
>       self.limit_cnt = self.limit_cnt - len(results)
1431c1440
       while result_pb.more_results() and self.limit_cnt > 0:
3377a3387
>     self.limit = arg_dict['limit']
3429c3439,3440
                                                         self.throttle_class,
>                                                         self.limit)
3689c3700
             'rps_limit', 'limit')
3723a3735
>   arg_dict['limit'] = None