Skip to content

Instantly share code, notes, and snippets.

@mgmarino
Created November 11, 2015 10:25
Show Gist options
  • Save mgmarino/991396f0ef26ae4b9e4d to your computer and use it in GitHub Desktop.
Save mgmarino/991396f0ef26ae4b9e4d to your computer and use it in GitHub Desktop.
import pynedm
import json
# Authentication
po = pynedm.ProcessObject(uri="http://raid.nedm1:5984",
username="admin",
password="""pw"""
)
acct = po.acct
# Grab the correct database
db = acct["nedm%2Fmeasurements"]
# Reads all data from a certain time
names_of_measurements_to_delete = [
"Test Mike",
"scheisse",
"test",
]
for f in names_of_measurements_to_delete:
query_dic = dict(descending=True,
endkey=[f],
startkey=[f + "{}", {}],
include_docs=True,
reduce=False
)
res = db.design('measurements').view('measurements').get(
params=query_dic).json()["rows"]
docs_to_delete = dict([(d["id"], d["doc"]["_rev"]) for d in res])
print("Deleting {} docs for measurement '{}'".format(len(docs_to_delete), f))
for d in docs_to_delete:
doc = db.document(d)
print(doc.delete(docs_to_delete[d]).json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment