【问题标题】:dowload app engine ndb entities via bulk exporter / bulk uploader通过批量导出/批量上传器下载应用引擎 ndb 实体
【发布时间】:2012-11-26 19:11:52
【问题描述】:

上下文:

我的模型类继承自基类:

class BaseModel(ndb.model):
  # commom fields and methods

class SpecificModel(BaseModel):
  # specific fields and methods

问题:

我想使用appengine bulkuploader service 导出SpecificModel 实体。

我已经定义了配置文件(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 ]

我使用以下命令下载数据:

  appcfg.py download_data --config_file=data_loader.py --filename=data.csv --kind=SpecificModel --url=http://url.appspot.com/_ah/remote_api

当我尝试下载数据时,我收到以下错误

google.appengine.ext.db.KindError: No implementation for kind 'SpecificModel'

有什么线索吗?

【问题讨论】:

    标签: google-app-engine app-engine-ndb


    【解决方案1】:

    看看source code

    您的模型将通过GetImplementationClass 查找

    implementation_class = db.class_for_kind(kind_or_class_key)
    

    db 模型的注册表将不包括您定义的任何ndb 模型。在ndb.Model._kind_map 中创建了一个类似的注册表,您定义的任何db 模型都不会在那里找到。

    注意:as I can tell 而言,没有相应的问题/功能请求要求批量加载程序中的ndb 支持或等效的ndb 批量加载程序。可能值得提交一份并由其主演。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-23
    • 2020-12-07
    • 1970-01-01
    • 2018-02-02
    • 2014-03-12
    • 1970-01-01
    相关资源
    最近更新 更多