首页 > 解决方案 > Python 到 Firebase

问题描述

我使用python将我的数据上传到firebase,而不是在实时数据库中为我的数据自动生成路径。我怎么能自己做呢?例子:

在此处输入图像描述

我不想要 MGRhisI5hSiYUs9fr0s,但我想要我自己的话。这是我的代码:

db = firebase.database()
data_to_upload = {
    "result": result
}
db.child("testResult").push(data_to_upload)

标签: pythonfirebasefirebase-realtime-database

解决方案


如果要指定路径,请不要使用push(),它会生成随机 ID。set()文档中所述,构建要更新和使用的位置的路径。

db.child("choose").child("your").child("path").set(data_to_upload)

推荐阅读