标签:ffffff 4.0 data start keyword amp timestamp 更新 需要
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}})
标签:ffffff 4.0 data start keyword amp timestamp 更新 需要
原文地址:http://www.cnblogs.com/hopelee/p/7246976.html