通过批量导出器/批量上传器下载应用引擎 ndb 实体 [英] dowload app engine ndb entities via bulk exporter / bulk uploader
问题描述
上下文:
我的模型类继承自基类:
My model classes inherit from a base class:
class BaseModel(ndb.model):
# commom fields and methods
class SpecificModel(BaseModel):
# specific fields and methods
问题:
我想使用 appengine bulkuploader 服务导出特定模型实体.
I want to export the SpecificModel entities using the appengine bulkuploader service.
我已经定义了配置文件(data_loader.py):
I have the defined the config file (data_loader.py):
import sys
sys.path.append('.') ## this is to ensure that it finds the file 'models.py'
from google.appengine.ext import ndb
from google.appengine.tools import bulkloader
from models import *
class SpecificModelExporter(bulkloader.Exporter):
def __init__(self):
bulkloader.Exporter.__init__(self, 'SpecificModel',
[('fieldOne', str, None),
('fieldTwo', str, None)
])
exporters = [ SpecificModelExporter ]
我使用以下命令下载数据:
I use the following command to download data:
appcfg.py download_data --config_file=data_loader.py --filename=data.csv --kind=SpecificModel --url=http://url.appspot.com/_ah/remote_api
当我尝试下载数据时,出现以下错误:
When I try to download the data I get the following error:
google.appengine.ext.db.KindError: No implementation for kind 'SpecificModel'
有什么线索吗?
推荐答案
查看 源代码:
您的模型将通过
implementation_class = db.class_for_kind(kind_or_class_key)
但是 db
模型的注册表将不包括您定义的任何 ndb
模型.在 ndb.Model._kind_map
中创建了一个类似的注册表,并且您定义的任何 db
模型都不会在那里找到.
but the registry of db
models will not include any ndb
models you've defined. A similar registry is created in ndb.Model._kind_map
and any db
models you had defined would not be found there.
注意:就作为我可以告诉没有相应的问题/功能请求要求在批量加载器或等效的 ndb
批量加载器中提供 ndb
支持.可能值得提交一份并主演.
NOTE: As far as I can tell there is no corresponding issue/feature request asking for ndb
support in the bulk loader or an equivalent ndb
bulk loader. It may be worth filing one and starring it.
这篇关于通过批量导出器/批量上传器下载应用引擎 ndb 实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!