from pymongo import MongoClient from bson.objectid import ObjectId from time import sleep MONGO_URI="mongodb://127.0.0.1:27017/default" db = MongoClient(MONGO_URI).get_default_database() while True: db.eventlog.insert_one({ "timestamp": "...", "event": "motion-detected", "started": "...", "finished": "...", "component": "motion-detect", "camera": "Server room", "action": "event", }) sleep(1)