Skip to content

Instantly share code, notes, and snippets.

@ymotongpoo
Created September 7, 2017 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ymotongpoo/2ee5dac1fcd05b8a6e6f00d60f6aaeaf to your computer and use it in GitHub Desktop.
Save ymotongpoo/2ee5dac1fcd05b8a6e6f00d60f6aaeaf to your computer and use it in GitHub Desktop.
Access Firebase Database using Firebase Admin SDK for Python
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