Created
November 11, 2015 10:25
-
-
Save mgmarino/991396f0ef26ae4b9e4d to your computer and use it in GitHub Desktop.
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
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