Created
September 10, 2015 07:50
-
-
Save stefan789/be75b26bceb48fcb1c03 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 json | |
import cloudant | |
import datetime as dt | |
# set up db and define functions | |
#acct = cloudant.Account(uri="http://10.155.59.88:5984") | |
acct = cloudant.Account(uri="http://raid.nedm1:5984") | |
res = acct.login("nedm_user", "") | |
assert res.status_code == 200 | |
db = acct["nedm%2Ffluxgate"] | |
des = db.design("slow_control_time_label") | |
the_view = des.view("slow_control_time_label") | |
# Reads all data from a certain time | |
des = db.design("document_type") | |
the_view = des.view("document_type") | |
# Can read all data with a certain key from a certain time | |
results = the_view.get(params=dict( | |
endkey=['log', 2015, 8, 9, 22, 0, 0], | |
startkey=['log', 2015, 8, 9, 14, 50], | |
include_docs=True, | |
reduce=False | |
) | |
).json() | |
all_ids = [(i["id"], (i["doc"]["log"], i["doc"]["timestamp"])) for i in results['rows']] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment