Created
September 7, 2017 15:31
-
-
Save ymotongpoo/2ee5dac1fcd05b8a6e6f00d60f6aaeaf to your computer and use it in GitHub Desktop.
Access Firebase Database using Firebase Admin SDK for Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import firebase_admin | |
from firebase_admin import auth, credentials, db | |
def main(): | |
cred = credentials.Certificate("./secrets.json") | |
app = firebase_admin.initialize_app(cred, options={ | |
"databaseURL": "https://<projectId>.firebaseio.com/" | |
}) | |
print(app.name) | |
data = { | |
"name": "shiumachi", | |
"age": 34 | |
} | |
ref = db.reference(path="/", app=app) | |
ref.child("users").set(data) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment