Skip to content

Instantly share code, notes, and snippets.

@ari-vedant-jain
Created November 28, 2016 19:04
Show Gist options
  • Save ari-vedant-jain/44b9333ee560cd6774a28799ea877830 to your computer and use it in GitHub Desktop.
Save ari-vedant-jain/44b9333ee560cd6774a28799ea877830 to your computer and use it in GitHub Desktop.
import pymongo
from pymongo import MongoClient
connection = MongoClient('localhost', 27017)
db = connection.omh
data = db.results
resultList = data.find()
#print collections in the database
db.collection_names()
#cursor = db['omh'].find({"header.schema_id.name": "blood-pressure"})
#load from collection 'omh' to a variable docs
docs = db['omh'].find()
print()
print('+-+-+-+-+-+-+-+-+-+-+-+-+-+')
for record in docs:
# print out the document
# print id, timestamp, value
print(record['header']['schema_id']['name'], record['body']['effective_time_frame']['date_time'], record['body']['systolic_blood_pressure']['value'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment