简体   繁体   English

是否可以使用Python将.json文件从BigQuery推送到Firebase?

[英]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”

Installation 安装

pip install firebase

Python Version Python版本

Firebase was written for python 3 and above and will not work correctly with python 2. Firebase是为python 3及更高版本编写的,无法在python 2上正常使用。

Add Firebase to your Application 将Firebase添加到您的应用程序

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)

Database 数据库

You can build paths to your data by using the child() method. 您可以使用child()方法构建数据的路径。

db = firebase.database()
db.child("BigQuery").child("Ojbect_1")

Save Data 保存数据

push

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.

相关问题 无法使用python将JSON文件从Google云存储加载到bigquery - Unable to load a JSON file from google cloud storage to bigquery using python 使用 Dataflow 管道 (python) 将多个 Json zip 文件从 GCS 加载到 BigQuery - Load multiple Json zip file from GCS to BigQuery using Dataflow pipeline (python) 使用 python 将.json 文件上传到 firebase 数据库 - upload .json file to firebase database using python 如何使用 Python 将 bigquery 返回的结果转换为 Json 格式? - How to convert results returned from bigquery to Json format using Python? 使用 python 从 JSON 文件中删除一些特定对象,然后将文件推送到 Elasticsearch Index - Delete some specific objects from a JSON file using python and then push the file to Elasticsearch Index 使用Python将文件从Google云端存储上传到Bigquery - Uploading a file from Google Cloud Storage to Bigquery using Python 使用 Python 从 csv 文件自动创建 BigQuery 架构/表 - Automate BigQuery schema/table creation from csv file using Python Json 架构文件将不会在 BigQuery 中执行 Python API - Json schema file will not execute in BigQuery Python API 是否可以使用 Python 将 Excel 工作表中的数据推送到数据库中? - Is it possible to push data from Excel sheet using Python into a database? 使用 Admin SDK 在 Python 中读取 Firebase 存储中的 JSON 文件,无需下载 - Read JSON file from Firebase Storage using Admin SDK in Python without download
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM