将实体导入本地GCP数据存储模拟器 [英] Importing Entities Into Local GCP Datastore Emulator

查看:127
本文介绍了将实体导入本地GCP数据存储模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此命令,我可以很容易地将实体导出到存储桶中:

I was able to export entities into a storage bucket without much difficulty with this command:

gcloud datastore export --kinds="KIND1,KIND2" --namespaces="NAMESPACE1,NAMESPACE2" gs://${BUCKET}

根据文档的导入,可以这样完成:

And according to the docs importing can be done like this:

gcloud datastore import gs://${BUCKET}/[PATH]/[FILE].overall_export_metadata

或类似这样:

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://datastore.googleapis.com/v1/projects/${PROJECT_ID}:import \
-d '{
"inputUrl": "gs://'${BUCKET}'/[PATH]/[FILE].overall_export_metadata",
}'

我的数据存储模拟器运行在localhost:8081上,是否可以使用curl命令将数据导入模拟器?在文档中没有关于它的任何内容,我尝试猜测许多URL,但是没有任何效果.

My datastore emulator is running on localhost:8081 is there anyway I can use this curl command to import the data to the emulator? There's nothing in the docs about it and I've tried guessing many urls but nothing works.

如果这不可能,那么还有其他方法可以填充我的本地仿真器,或者更好地将本地应用程序引擎连接到生产数据存储区吗?

If this is impossible, is there another way I can fill my local emulator or better yet connect the local app engine to the production datastore?

显然,过去曾经有一种使用csv文件进行导出和导入的方法:

Apparently there used to be a way to export and import using csv files:

Google云数据存储区模拟器初始数据

但此后已弃用.

推荐答案

数据存储模拟器现在支持导入和导出:

The Datastore Emulator now supports import and export:

导入:

curl -X POST localhost:8081/v1/projects/[PROJECT_ID]:import \
-H 'Content-Type: application/json' \
-d '{"input_url":"[ENTITY_EXPORT_FILES]"}'

导出:

curl -X POST localhost:8081/v1/projects/[PROJECT_ID]:export \
-H 'Content-Type: application/json' \
-d '{"output_url_prefix":"EXPORT_DIRECTORY"}'

https://cloud.google.com/datastore/docs /tools/emulator-export-import

这篇关于将实体导入本地GCP数据存储模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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