Last active
January 23, 2020 15:02
-
-
Save Karasuni/d09993774d1736be757bca35c8ec368d to your computer and use it in GitHub Desktop.
Use as `<command w/ stdout output> | python3 upload-to-firestore.py collectiondb-ref`
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
#!/usr/bin/python3 | |
import json | |
import sys | |
import datetime | |
import firebase_admin | |
from firebase_admin import credentials | |
from firebase_admin import firestore | |
json_obj = json.load(sys.stdin) | |
collection_ref = sys.argv[1] | |
json_obj['system_time'] = datetime.datetime.now() | |
cred = credentials.Certificate('/path/to/certificate.json') | |
firebase_admin.initialize_app(cred) | |
firestore.client().collection(collection_ref).add(json_obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment