python - 如何从 python 代码将 Firebase 导出为 JSON?
问题描述
我必须改进使用 Firebase 数据库的 python 项目(需要在数据库中进行更改)。该项目的开发人员消失了,我无法访问 Google 帐户,但数据库仍然响应,我可以访问该 throw 程序。
存储在代码中的东西:
"fire": {
"type": "service_account",
"project_id": "...",
"private_key_id": "...",
"private_key": "-----BEGIN PRIVATE KEY-----\n ...",
"client_email": "...@appspot.gserviceaccount.com",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/...gserviceaccount.com"
}
连接代码:
import firebase_admin
cert = self.data.get('fire') #parsing JSON into dict
cred = credentials.Certificate(cert)
firebase_admin.initialize_app(cred)
self.db = firestore.client()
我需要将数据库导出为 JSON,这样我就可以创建一个相同的新数据库并进行所需的更改。
解决方案
推荐阅读
- java - 由于图像上传,重定向后页面刷新
- php - 字符串时间戳到 int,然后在 PHP 中用它创建一个 DateTime
- django - 如果用户与登录的管理员相同,则 Django Channels 聊天应用程序不会打开线程
- crm - 防止删除某些产品
- android - 带有背景颜色的菜单项
- ios - 以编程方式禁用 iOS 模拟器“连接硬件键盘”
- vue.js - axios快速请求时不返回数据
- python - 如何在 Python 中将新行附加到现有的 CSV 文件?
- xml - 如何使用本地 XML 文件创建企业服务?
- javascript - Firebase Cloud Functions - 如何调用另一个函数并返回对象