Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pymongo import MongoClient
- from Sensors import *
- import time
- client = MongoClient()
- client = MongoClient('10.1.10.113', 27017)
- while True:
- TempSetup()
- db = client.SensorData.Temperature
- TempData = TempRead()
- print(TempData , " 1")
- print(time.asctime( time.localtime(time.time()) ))
- posts = db
- post_data = {
- 'Temp': str(TempData),
- 'time' : time.asctime( time.localtime(time.time()) ),
- }
- result = posts.insert_one(post_data)
- print(TempData , '2')
- print('One post: {0}'.format(result.inserted_id))
- time.sleep(5)
- results = db.count()
- print(results)
- time.sleep(15)
- client.close()
- > show dbs
- SensorData 0.000GB
- admin 0.000GB
- config 0.000GB
- local 0.000GB
- mylib 0.000GB
- > use SensorData
- switched to db SensorData
- > show collections;
- Temperature
- users
- > db.Temperature.find()
- { "_id" : ObjectId("5d09a25626336fe1d794b941"), "Temp" : "1", "time" : -5 }
- { "_id" : ObjectId("5d09a4e326336fe1d794b942"), "Temp" : "1", "time" : "Tue Jun 18 20:56:23 2019" }
- 109.85
- 109.85 1
- Wed Jun 19 13:08:42 2019
- 109.85 2
- One post:5d09a25626336794b942
- 84
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement