[英]Is it possible to push .json file from BigQuery to Firebase using Python?
I fetched the data (.csv) from BigQuery. 我从BigQuery提取了数据(.csv)。 I have done some data cleaning using Python and created a new table in BigQuery.
我已经使用Python完成了一些数据清理工作,并在BigQuery中创建了一个新表。 Now, I like to get .json file for that table and push it to firebase using Python.
现在,我想获取该表的.json文件,然后使用Python将其推送到Firebase。
I am quite new to Firebase and stuck here. 我刚接触Firebase并停留在这里。 Could anyone please help here?
有人可以帮忙吗?
Yes you can :) by using the python package 'firebase' 是的,您可以:)通过使用python软件包“ firebase”
pip install firebase
Firebase was written for python 3 and above and will not work correctly with python 2. Firebase是为python 3及更高版本编写的,无法在python 2上正常使用。
Your Google's Firebase configuration data can be found on Firebase > Settings > Project Settings Scroll to bottom > Add to web app > config 您可以在Firebase >设置>项目设置上找到Google的Firebase配置数据滚动到底部 >添加到Web应用>配置
For use with only user based authentication we can create the following configuration: 仅与基于用户的身份验证一起使用,我们可以创建以下配置:
from firebase import Firebase
config = {
"apiKey": "apiKey",
"authDomain": "projectId.firebaseapp.com",
"databaseURL": "https://databaseName.firebaseio.com",
"storageBucket": "projectId.appspot.com"
}
firebase = Firebase(config)
You can build paths to your data by using the child()
method. 您可以使用
child()
方法构建数据的路径。
db = firebase.database()
db.child("BigQuery").child("Ojbect_1")
To save data with a unique, auto-generated, timestamp-based key, use the push()
method. 要使用唯一的,自动生成的,基于时间戳的密钥保存数据,请使用
push()
方法。
data = {"data": <More JSON Data>}
db.child("BigQuery").child("Object_2").set(data)
set
To create your own keys use the set()
method. 要创建自己的密钥,请使用
set()
方法。 The key in the example below is "Object_2". 下例中的键为“ Object_2”。
db.child("BigQuery").child("Object_2").remove()
update
To update data for an existing entry use the update()
method. 要更新现有条目的数据,请使用
update()
方法。
db.child("BigQuery").child("Object_2").update({"data": <Updated More JSON Data>})
remove
To delete data for an existing entry use the remove()
method. 要删除现有条目的数据,请使用
remove()
方法。
db.child("BigQuery").child("Object_2").remove()
I hope this helps :) More information / full docs: https://pypi.org/project/firebase 我希望这会有所帮助:)更多信息/完整文档: https : //pypi.org/project/firebase
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.