|
@@ -2,36 +2,44 @@ from pymongo import MongoClient
|
|
|
from bson import ObjectId
|
|
|
from lib.mogodb_helper import MongoDBInterface
|
|
|
|
|
|
-#复制mongo数据源 从一个源到另一个源
|
|
|
-
|
|
|
+#复制mongo数据源 从一个源1到另一个源3
|
|
|
+# 从源1中导入到源3 ,和源2 一样的数据
|
|
|
#mongo库 源1
|
|
|
MongodbConfig = {
|
|
|
- "ip_port": "127.0.0.1:27092",
|
|
|
+ "ip_port": "127.0.0.1:27088",
|
|
|
"user": "viewdata",
|
|
|
"password": "viewdata",
|
|
|
- "db": "qfw",
|
|
|
+ "db": "qfw_ai",
|
|
|
}
|
|
|
+
|
|
|
mdb = MongoDBInterface(MongodbConfig)
|
|
|
-#mongo库 源2
|
|
|
+#mongo库 源3
|
|
|
MongodbConfigInsert = {
|
|
|
- "ip_port": "192.168.3.166:27082",
|
|
|
- "db": "zhengluming_27082",
|
|
|
+ "ip_port": "192.168.3.149:27180",
|
|
|
+ "db": "data_quality",
|
|
|
}
|
|
|
insertdb = MongoDBInterface(MongodbConfigInsert)
|
|
|
|
|
|
+max_id = ObjectId("0" * 24)
|
|
|
+# max_id = ObjectId("655ec5609aed6eb2ffa654ca")
|
|
|
+
|
|
|
# 连接MongoDB数据库
|
|
|
-with MongoClient('192.168.3.166', 27082) as client:
|
|
|
- db = client.zhengluming
|
|
|
- coll = db.f_sourceinfo_HP_channel_succes_data
|
|
|
- for row in coll.find({"historyId": "655707de7f39550da1f59d3d"}, {"id": 1}).sort("_id", 1):
|
|
|
- _id = row.get("id", "")
|
|
|
- print(row["_id"])
|
|
|
+with MongoClient('192.168.3.149', 27180) as client:
|
|
|
+ #源2
|
|
|
+ db = client.data_quality
|
|
|
+ coll = db.standard_sample_data
|
|
|
+ for row in coll.find().sort("_id", 1):
|
|
|
+ # for item in coll_user.find({"_id": {"$gte": max_id}}).sort("_id", 1):
|
|
|
+ _id = row.get("_id", "")
|
|
|
+ # print(row["_id"])
|
|
|
if _id:
|
|
|
m_id = ObjectId(_id)
|
|
|
result=mdb.find_by_id("bidding",m_id)
|
|
|
- result["id"]=str(row["_id"])
|
|
|
+ if result==None:
|
|
|
+ print(row["_id"]+"在大库没找到")
|
|
|
if result:
|
|
|
- insertdb.insert2db("update_data",result)
|
|
|
+ result["_id"] = str(row["_id"])
|
|
|
+ insertdb.insert2db("standard_sample_data_all",result)
|
|
|
|
|
|
# 关闭数据库连接
|
|
|
client.close()
|