Python - Firebase 数据库引用错误

标签 python firebase flask firebase-realtime-database

我需要更新我的 Firebase 数据库中的某些节点,所以这就是我正在做的:

from firebase_admin import db

def update_data_in_firebase(gid, account_id, location_id, data_to_update):
    firebase_url = 'saved_locations/{}/accounts/{}/locations/{}'.format(gid, account_id, location_id)
    ref = db.reference(path=firebase_url)
    ref.update(data_to_update)

所以,上面的代码是我试图更新 Firebase 节点中的数据,但我收到此错误:
Invalid databaseURL option: "None". databaseURL must be a non-empty URL string.
当然,我检查了 firebase URL 并且它匹配,所以问题不是 URL,或者,我在路径中遗漏了一些东西,我的意思是,我应该使用绝对路径的相对路径。

最佳答案

正如问题的评论中提到的,数据库网址 没有定义。

回答:

cred = credentials.Certificate('your_config.json')
firebase_admin = firebase_admin.initialize_app(cred, {'databaseURL': 'https://your-firebase-db'})

在 Firebase 的主要文档中,我找不到我的应用初始化错误:
Firebase Admin Docs
但是在Realtime Database - Admin (Get Started) ,有一个片段,它们初始化定义了 的 Firebase 应用程序。数据库网址

关于Python - Firebase 数据库引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49503297/

相关文章:

javascript - 如何正确使用 mechanize 来抓取 AJAX 网站

python - 将 QrCodeWidget(或 PlotArea)与鸭嘴兽一起使用

javascript - Angular 前端和 Python 后端的 CORS 问题

javascript - 为复杂的 Firebase 查询提供 Angular 服务

python-3.x - 如何将 Bootstrap 验证添加到 WTForms

python - 是否可以在 HTML 上嵌入和运行 Python 代码?

python - Pandas 饲养 : AttributeError: module 'pandas.core' has no attribute 'format'

python - 直接从 numpy 数据创建 blender 网格?

swift - Firebase 身份验证 : user profile changes are not synced to other devices?

firebase - ServiceAccountKey.json无法下载