Last active
August 14, 2018 09:03
-
-
Save MksYi/ac14a579c66ee55ee5fd08d29996b5cd to your computer and use it in GitHub Desktop.
Firebase 寫入測試
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 firebase_admin | |
from firebase_admin import credentials | |
from firebase_admin import firestore | |
cred = credentials.Certificate("stust-game-firebase-adminsdk-z8f9e-565f1cf637.json") | |
firebase_admin.initialize_app(cred) | |
db = firestore.client() | |
doc_ref = db.collection('Q1', 'DOC1', 'Q2').document('DOC2') | |
#Method 1 | |
doc_ref.set({ | |
'姓名': '劉德華', | |
'年紀': '23', | |
'工作': '爆肝工程師', | |
}) | |
#Method 2 | |
data = { | |
'姓名': '劉德華', | |
'年紀': '23', | |
'工作': '爆肝工程師', | |
} | |
doc_ref.set(data) | |
print('Done') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment