我需要将MongoDB自动生成的UUID插入我的另一列,如下面的代码,
try:
conn = MongoClient('localhost', 27017)
print("Connected successfully!!!")
except:
print("Could not connect to MongoDB")
# database
db = conn.hash
# Created or Switched to collection names: my_gfg_collection
collection = db.ib
unix = datetime.utcnow()
unixtime = calendar.timegm(unix.utctimetuple())
emp_rec1 = {
"tib" : "8f7074d8-a520-4f7d-b2d3-09dc36acb5fd",
"tib_name" : "TPEMAIL",
"mail_box_name" : "Test Gmail",
"id_mail_box" : "use here when generate to UUID v4 - MONGO",
}
# Insert Data
rec_id1 = collection.insert_one(emp_rec1)
如上面的代码所示,我需要将自动生成的UUID(_id:5b5a36d40abd950a88003fc3)插入我的id_mail_box
列中。