1
1

More than 3 years have passed since last update.

Python3 で Cloud Firestore のデータを削除 (Delete)

Last updated at Posted at 2020-01-24

こちらで作成したデータのひとつを削除します。
Python3 で Cloud Firestore のデータを作成 (Create)

firestore_delete.py
#! /usr/bin/python
#
import sys
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore

# ------------------------------------------------------------------
sys.stderr.write("*** 開始 ***\n")
key_in = sys.argv[1]
#
print(key_in)
#
cred = credentials.ApplicationDefault()
firebase_admin.initialize_app(cred, {
  'projectId': 'my-project-2020-01-22',
})

db = firestore.client()
#
db.collection('cities').document(key_in).delete()
#
sys.stderr.write("*** 終了 ***\n")
# ------------------------------------------------------------------

実行コマンド

export GOOGLE_APPLICATION_CREDENTIALS="***.json"
./firestore_delete.py t0924

次のバージョンで確認しました。

$ python --version
Python 3.8.6
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1