-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopulate_database.py
More file actions
21 lines (17 loc) · 901 Bytes
/
populate_database.py
File metadata and controls
21 lines (17 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from pymongo import MongoClient
from random import randint
# Connect to MongoDB
client = MongoClient('localhost', 27017)
db = client['robotic_dashboard']
collection = db['robot_data']
# Sample robotic data
data = [
{'battery_level': randint(50, 100), 'status': 'idle', 'logs': ['Log 11', 'Log 12', 'Log 13']},
{'battery_level': randint(50, 100), 'status': 'active', 'logs': ['Log 14', 'Log 15', 'Log 16']},
{'battery_level': randint(50, 100), 'status': 'active', 'logs': ['Log 17', 'Log 18', 'Log 19']},
{'battery_level': randint(50, 100), 'status': 'charging', 'logs': ['Log 21', 'Log 22', 'Log 23']},
{'battery_level': randint(50, 100), 'status': 'active', 'logs': ['Log 24', 'Log 25', 'Log 26']},
{'battery_level': randint(50, 100), 'status': 'charging', 'logs': ['Log 27', 'Log 28', 'Log 29']}
]
collection.insert_many(data)
print("Sample data inserted into MongoDB.")