-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtest.py
executable file
·40 lines (34 loc) · 971 Bytes
/
dtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pymongo
from datetime import datetime
from datetime import timedelta
from random import seed
from random import randint
#myclient = pymongo.MongoClient("mongodb://mongodbuser:mdb_user@localhost:27017/")
#print(myclient.list_database_names())
myclient = pymongo.MongoClient("mongodb://edgedbuser:edgedb@localhost:27017/?authSource=edgedb")
mydb = myclient["edgedb"]
mycoll = mydb["user"]
mytscoll = mydb["tsdata"]
#for x in mycoll.find():
# print(x)
#for x in mycoll.find({},{ "name": "shanky"}):
# print(x)
x = mytscoll.delete_many({})
print(x.deleted_count, " documents deleted.")
for dev in range(1,6):
for x in range(20):
td = x*3
tstamp = datetime.now()+timedelta(minutes=td)
temp = randint(30, 40)
humidity = randint(50, 80)
pressure = randint(90, 120)
data = {
"pressure":pressure,
"humidity":humidity,
"temp":temp,
"ts": tstamp,
"deviceId": dev
}
mytscoll.insert_one(data);
for x in mytscoll.find():
print(x)