1. import pymongo
1. 初始化 Mongo 客户端
client=pymongo.MongoClient(mongodb://10.85.39.45:8188,10.85.39.43:8188,10.85.39.31:8188,10.85.39.32:8188,10.85.39.33:8188,10.85.39.34:8188,10.85.32.16:8188,10.85.32.33:8188,10.85.39.35:8188,10.85.39.27:8188)
2. 初始化数据库
mongo_database = client[db_name]
3. 初始化表
stat_tbl = mongo_database[stat_tbl_name]
4. 在表中按照键值查找数据
start_time_doc = stat_tbl.find_one({‘keyword‘: keyword_name})
start_time_doc下可能还有二级键值,需要用start_time_doc[‘start_time‘]访问
5. 在表中更新数据
stat_tbl.update({‘keyword‘: keyword_name}, {‘$set‘: {‘start_time‘: timestamp}})
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff }
span.s1 { }
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff }
span.s1 { }
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff }
span.s1 { }
span.s2 { color: #c33720 }
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #5230e1; background-color: #ffffff }
span.s1 { color: #c33720 }
span.s2 { }