Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. from pymongo import MongoClient
  2. from Sensors import *
  3. import time
  4.  
  5. client = MongoClient()
  6. client = MongoClient('10.1.10.113', 27017)
  7. while True:
  8. TempSetup()
  9. db = client.SensorData.Temperature
  10. TempData = TempRead()
  11. print(TempData , " 1")
  12. print(time.asctime( time.localtime(time.time()) ))
  13. posts = db
  14. post_data = {
  15. 'Temp': str(TempData),
  16. 'time' : time.asctime( time.localtime(time.time()) ),
  17. }
  18. result = posts.insert_one(post_data)
  19. print(TempData , '2')
  20. print('One post: {0}'.format(result.inserted_id))
  21. time.sleep(5)
  22. results = db.count()
  23. print(results)
  24. time.sleep(15)
  25. client.close()
  26.  
  27. > show dbs
  28. SensorData 0.000GB
  29. admin 0.000GB
  30. config 0.000GB
  31. local 0.000GB
  32. mylib 0.000GB
  33. > use SensorData
  34. switched to db SensorData
  35. > show collections;
  36. Temperature
  37. users
  38. > db.Temperature.find()
  39. { "_id" : ObjectId("5d09a25626336fe1d794b941"), "Temp" : "1", "time" : -5 }
  40. { "_id" : ObjectId("5d09a4e326336fe1d794b942"), "Temp" : "1", "time" : "Tue Jun 18 20:56:23 2019" }
  41.  
  42. 109.85
  43. 109.85 1
  44. Wed Jun 19 13:08:42 2019
  45. 109.85 2
  46. One post:5d09a25626336794b942
  47. 84
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement