couch_delete.py
#! /usr/bin/python3
# -*- coding: utf-8 -*-
#
# couch_delete.py
#
# Jul/27/2020
# ----------------------------------------------------------------
import sys
import json
import requests
#
# ----------------------------------------------------------------
sys.stderr.write("*** 開始 ***\n")
#
key_in = sys.argv[1]
print("%s" % key_in)
#
url_json = 'http://localhost:5984/nagano'
url_key = url_json + '/' + key_in
#
rr=requests.get(url_key)
#
unit_aa = json.loads(rr.text)
#
if ('_rev' in unit_aa):
print(unit_aa['_rev'])
url_del = url_key + '?rev=' + unit_aa['_rev']
rr=requests.delete(url_del)
else:
sys.stderr.write("*** not exist ***\n")
print(unit_aa)
#
sys.stderr.write("*** 終了 ***\n")
# ----------------------------------------------------------------
実行
./couch_delete.py t2024