通过批量导出器/批量上传器下载应用引擎ndb实体 [英] dowload app engine ndb entities via bulk exporter / bulk uploader

查看:135
本文介绍了通过批量导出器/批量上传器下载应用引擎ndb实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:

我的模型类继承自一个基类:

 <$ c $ b> class BaseModel(ndb.model):
#commom字段和方法
$ b $ class SpecificModel(BaseModel):
#特定字段和方法


$ b

问题:

我想使用导出SpecificModel实体href =https://developers.google.com/appengine/docs/python/tools/uploadingdata =nofollow> appengine bulkuploader服务



我定义了配置文件(data_loader.py):

  import sys 
sys.path.append ('。')##这是为了确保它从google.appengine.ext中找到文件'models.py'
从google.appengine.tools导入ndb
导入bulkloader
从模型导入*

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:对'SpecificModel'没有实现

任何线索?

解决方案

查看源代码

您的模型将在 GetImplementa中查找tionClass via

  implementation_class = db.class_for_kind(kind_or_class_key)

但是 db 模型的注册表不会包含任何 ndb 您定义的模型。在 ndb.Model._kind_map 中创建了一个类似的注册表,并且您已经定义的任何 db 模型都不会在那里找到。



注意:至我可以看出没有对应的问题/功能请求在批量加载程序中要求 ndb 支持,或者相当于 ndb 批量加载程序。这可能值得提交一个并主演它。


Context:

My model classes inherit from a base class:

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

class SpecificModel(BaseModel):
  # specific fields and methods

Problem:

I want to export the SpecificModel entities using the appengine bulkuploader service.

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'

Any clues?

解决方案

Have a look at the source code:

Your model will be looked up in GetImplementationClass via

implementation_class = db.class_for_kind(kind_or_class_key)

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.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆