小编gbo*_*ine的帖子

python中的谷歌云函数读取firebase实时数据

我正在编写一个简单的谷歌云函数来学习,使用新的 Python3.7 选项,我想读/写一些数据到 Firebase 实时数据库。

我找到了一些可以使用 Firestore 的信息,但现在我需要使用实时数据库。

# global
import firebase_admin

from firebase_admin import db
# from firebase_admin import firestore

default_app = firebase_admin.initialize_app()

def check_prices_updates(request):
"""Responds to any HTTP request.
Args:
    request (flask.Request): HTTP request object.
Returns:
    The response text or any set of values that can be turned into a
    Response object using
    make_response 
"""

collection = 'pricelist'
mybase = db.reference(collection)

   ....[other code]

return "OK"
Run Code Online (Sandbox Code Playgroud)

这是我的代码的摘录,文档说initialize_app()必须将其留空以收集项目默认凭据。

我调用 db.reference(collection) 的行给了我一个例外:

ValueError:无效的 databaseURL 选项:“无”。databaseURL 必须是非空 URL 字符串。

好像配置参数没有显示请求的键“databaseURL”。以 …

python firebase firebase-realtime-database google-cloud-functions

6
推荐指数
1
解决办法
1019
查看次数