Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 通过“firebase”和“gcloud”启动firestore emulator之间的区别?_Python_Firebase_Google Cloud Platform_Google Cloud Firestore_Gcloud - Fatal编程技术网

Python 通过“firebase”和“gcloud”启动firestore emulator之间的区别?

Python 通过“firebase”和“gcloud”启动firestore emulator之间的区别?,python,firebase,google-cloud-platform,google-cloud-firestore,gcloud,Python,Firebase,Google Cloud Platform,Google Cloud Firestore,Gcloud,通过以下方式启动firestore emulator有什么区别: firebase emulators:start --only firestore 以及: 这两个选项都允许我的python应用程序实现与数据库的连接,如下所示: import google from google.cloud import firestore os.environ["FIRESTORE_EMULATOR_HOST"] = "localhost:8081" os.envi

通过以下方式启动firestore emulator有什么区别:

firebase emulators:start --only firestore
以及:

这两个选项都允许我的python应用程序实现与数据库的连接,如下所示:

import google
from google.cloud import firestore

os.environ["FIRESTORE_EMULATOR_HOST"] = "localhost:8081"
os.environ["FIRESTORE_EMULATOR_HOST_PATH"] = "localhost:8081/firestore"
os.environ["FIRESTORE_HOST"] = "http://localhost:8081"

credentials = mock.Mock(spec=google.auth.credentials.Credentials)
client = firestore.Client(credentials=credentials)
我自己注意到的一个区别是,
firebase
似乎尊重我的
firebase.json
,特别是指定的主机端口,如下所示:

{
  "emulators": {
    "firestore": {
      "port": "8081"
    }
  }
}

另一方面,
gcloud
忽略
firebase.json
,而是选择一个随机端口,除非我通过
--host port
显式传递端口。这是这两个工具之间更大区别的一部分吗?还有什么其他区别吗?

我一直在查看这两个工具的文档,它们做的事情几乎相同

使用可以启动多个Firebase产品的模拟器,而允许启动GCP模拟器。Firestore只是他们共同拥有的一种产品,因此他们的效用应该相同或相似

关于功能差异,
firebase
提供了
--import
--export-on-exit
标志,允许您在模拟会话之间保存和恢复数据。它还提供了一种可视化用户如何处理当前查询的方法

除了这些功能外,我还要注意设置端口和规则文件的不同方法:

  • firebase模拟器
    使用该文件
  • gcloud beta模拟器
    使用标志和来实现相同的功能
请注意,GCP上的版本处于启用状态,因此其官方支持可能有限,并且可能会发生更改。还请注意,在上,Firebase CLI是如何代替gcloud使用的

最后,您应该使用首选工具,因为它们都朝着模拟Firestore的相同目标工作。如果您已经在使用Firebase CLI,我建议您继续使用它;如果您使用的是
gcloud
,请使用它

{
  "emulators": {
    "firestore": {
      "port": "8081"
    }
  }
}