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

查看:28
本文介绍了将实体导入本地 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 命令将数据导入模拟器吗?文档中没有关于它的任何内容,我尝试猜测许多网址,但没有任何效果.

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 云数据存储模拟器初始化数据

但此后已被弃用.

推荐答案

Datastore Emulator 现在支持导入和导出:

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天全站免登陆