init
This commit is contained in:
commit
b8db79d56f
40
main.py
Normal file
40
main.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
""""
|
||||||
|
用于同步 atrr 配置
|
||||||
|
1.关键指标 运营日报
|
||||||
|
2.新手漏斗
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pymongo
|
||||||
|
|
||||||
|
# source_mongo_uri = 'mongodb://root:Legu2020@dds-hp35c58764c35aa41188-pub.mongodb.huhehaote.rds.aliyuncs.com:3717,dds-hp35c58764c35aa42908-pub.mongodb.huhehaote.rds.aliyuncs.com:3717/admin?replicaSet=mgset-421510732'
|
||||||
|
# local_mongo_uri = 'mongodb://root:iamciniao@119.29.176.224:27017/?authSource=admin&readPreference=primary&ssl=false'
|
||||||
|
|
||||||
|
source_mongo_uri = os.getenv('remote_mdb_uri')
|
||||||
|
local_mongo_uri = os.getenv('local_mdb_uri')
|
||||||
|
|
||||||
|
|
||||||
|
s_cline = pymongo.MongoClient(source_mongo_uri)
|
||||||
|
d_cline = pymongo.MongoClient(local_mongo_uri)
|
||||||
|
|
||||||
|
|
||||||
|
def get_pname():
|
||||||
|
data = s_cline['admin_game']['kv'].find_one({'k': 'attr_sync'})
|
||||||
|
return data['v']
|
||||||
|
|
||||||
|
|
||||||
|
def sync_data(game):
|
||||||
|
s_coll = s_cline['game_' + game]['attr']
|
||||||
|
d_coll = d_cline['game_' + game]['attr']
|
||||||
|
for pname in get_pname():
|
||||||
|
where = {'pname': pname}
|
||||||
|
doc = s_coll.find_one(where, {'_id': 0})
|
||||||
|
if not doc:
|
||||||
|
continue
|
||||||
|
d_coll.update_one(where, {'$set': doc},upsert=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
game = sys.argv[1]
|
||||||
|
sync_data(game)
|
Loading…
Reference in New Issue
Block a user