我正在尝试在本地测试Google的云数据存储区。我的测试步骤是:
我按照所有步骤使用本地模拟器
gcloud beta emulators datastore start
gcloud beta emulators datastore env-init
但是,在python中,当使用以下命令访问云数据存储时,它总是将数据直接保存到谷歌云而不是将它们保存到本地模拟器
#Imports the Google Cloud client library
from google.cloud import datastore
# Instantiates a client
datastore_client = datastore.Client()
sample_entry = some_data
# Saves the entity
datastore_client.put(sample_entry)
您似乎无法指定库使用本地数据存储模拟器,就像它们在Node.js客户端中提供的那样
var datastore = gcloud.datastore({
apiEndpoint: "http://localhost:8380"
});
我的问题是,如何让google云数据存储python库使用本地模拟器而不是直接使用云
答案 0 :(得分:0)
您需要gcloud beta emulators datastore env-init
。
myDriver.findElement.ById("select-pcsl-9777-protocol")
仅打印设置必要环境变量的命令。
答案 1 :(得分:0)
您可以尝试类似
的内容if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
# Production
else:
# Local development server
您可以在此处关注更多内容,https://cloud.google.com/appengine/docs/standard/python/tools/using-local-server