google-cloud-datastore - 云函数 python 访问数据存储
问题描述
我正在寻找有关如何使用云函数 (python) 访问数据存储的教程或文档。
但是,似乎只有 nodejs 的教程。 https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/functions/datastore 有人可以帮帮我吗?谢谢
解决方案
从 python 中的云函数访问数据存储不需要特殊设置。
您只需要像往常一样添加和使用数据存储客户端google-cloud-datastore
。requirements.txt
要求.txt
# Function dependencies, for example:
# package>=version
google-cloud-datastore==1.8.0
主文件
from google.cloud import datastore
datastore_client = datastore.Client()
def foo(request):
"""Responds to any HTTP request.
Args:
request (flask.Request): HTTP request object.
Returns:
The response text or any set of values...
"""
query = datastore_client.query(kind=<KindName>)
data = query.fetch()
for e in data:
print(e)
阅读更多:
推荐阅读
- c# - ClickOnce 应用程序启动后不显示任何内容
- javascript - React Router v4 - 嵌套路由不起作用
- laravel - 尝试将 laravel/homestead 添加到 Vagrant 时出现错误:盒子无法正确解包
- android - Android Activity 变白
- scala - 记录器在集群上的 spark UDF 内不工作
- reactjs - 为什么 React 中没有自动生成数组的键?
- ajax - Chrome 控制台日志中的 AJAX 请求错误 POST 0 ()
- php - 如何从另一个类更新另一个类的功能
- javascript - 需要 javascript 来检查子网 CIDR 是否在 VPC 范围内
- python - 用 python 数据框格式化 csv 数据