id: 12737    nodeId: 12737    type: General    point: 10.0    linkPoint: .0    maker: cella    permission: linkable    made at: 2020.03.24 05:09    edited at: 2022.02.10 07:19
how to upload data to Firestore using python (Firebase Admin SDK)
https://cloud.google.com/firestore/docs/quickstart-servers#firestore_setup_dataset_pt1-python_async
Quickstart using a server client library

먼저 키 생성:
Firebase concole > settings 아이콘 > service account > 새 비공개키 생성 > xxx.json is downloaded

install firestore module
// note that pip is the same with pip3

$ pip install virtualenv
$ virtualenv env
$ source env/bin/activate

(env) $ pip install --upgrade google-cloud-firestore
(env) $ export GOOGLE_APPLICATION_CREDENTIALS="xxx.json"
(env) $ vi test.py
from google.cloud import firestore

# The `project` parameter is optional and represents which project the client
# will act on behalf of. If not supplied, the client falls back to the default
# project inferred from the environment.
db = firestore.Client(project='readwrite-de55f')

doc_ref = db.collection("caches").document("testfromPythonClient")
doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815})

(env) $ python test.py



Return to 가족회관 or how to upload data to Firestore using python (Firebase Admin SDK)