#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
# ÐÞ¸ÄÕ˺źó׺
|
#-------------------------------------------------------------------------------
|
#
|
# Ð޸ıí
|
# GameLog: tagDBPlayerInfoLog
|
# GameUser: tagDSAccount tagDBPlayer tagDBBillboard
|
# ¿ÉÄÜ»áʹÓÃÒÑ´¦Àí tagAccIDSendPrize tagDBGMIP tagGameWorldEvent
|
# ×ֶβ»È·¶¨ÎÞ·¨´¦ÀíµÄ tagUniversalGameRec ÐèÒªÑз¢ÈËÔ±ÅäºÏ
|
# ²»»áʹÓõIJ»´¦Àí tagDBMailList tagExpiation tagPetExpiation tagAccCoins
|
#-------------------------------------------------------------------------------
|
# ver=1.2
|
#-------------------------------------------------------------------------------
|
|
import pymongo
|
from Collections import (DataServerPlayerData, )
|
DBConfig = __import__('Config.DBConfig')
|
|
|
def changeAccID(accID, spid, serverid):
|
accpeice = accID.split("@")
|
if len(accpeice) < 3:
|
return ""
|
|
if not spid:
|
spid = accpeice[-2]
|
|
if not serverid:
|
serverid = accpeice[-1]
|
|
accID = accID.replace("@%s@%s"%(accpeice[-2], accpeice[-1]), "@%s@%s"%(spid, serverid))
|
return accID
|
|
def main():
|
|
print "Connect %s:%s "%(DBConfig.USER_DB_IP, DBConfig.USER_DB_PORT)
|
con = pymongo.Connection(DBConfig.USER_DB_IP, DBConfig.USER_DB_PORT)
|
|
db = con.admin
|
|
if not db.authenticate(DBConfig.userdb_user, DBConfig.userdb_pwd):
|
print "name(%s) or password(%s) error!, Plz try input them to continue again!"%(DBConfig.userdb_user, DBConfig.userdb_pwd)
|
return
|
|
db = con[DBConfig.USER_DB_NAME]
|
# ÐÞ¸ÄÍæ¼Ò±íºÍÕ˺űíÖеÄÍæ¼ÒÕ˺Å
|
col = db['tagDSAccount']
|
|
cnt = 0
|
for rec in col.find():
|
accID = rec["ACCID"]
|
accountObj = DataServerPlayerData.tagDSAccount()
|
accountObj.ACCID = accID
|
# ¼ÓÔØÊý¾Ý
|
if not accountObj.adoLoad(col):
|
print 'accid %s not found!'%accID
|
continue
|
|
newAccID = changeAccID(accID, DBConfig.Spid, DBConfig.Serverid)
|
if not newAccID:
|
continue
|
# ÔØÈëÐÂÕ˺Å
|
accountObj.ACCID = newAccID
|
rec = accountObj.getRecord()
|
col.update({'ACCID':accID}, {'$set':rec}, False, False, True, True)
|
cnt += 1
|
print 'table:tagDSAccount update successfully! cnt=%s changeto %s-%s'%(cnt, DBConfig.Spid, DBConfig.Serverid)
|
|
|
for table in ['tagDBPlayer', 'tagAccIDSendPrize', 'tagDBGMIP', 'tagGameWorldEvent']:
|
# ÐÞ¸ÄÍæ¼Ò±íºÍÕ˺űíÖеÄÍæ¼ÒÕ˺Å
|
colPlayer = db[table]
|
cnt = 0
|
keyName = "AccID"
|
for rec in colPlayer.find():
|
accID = rec[keyName]
|
|
newAccID = changeAccID(accID, DBConfig.Spid, DBConfig.Serverid)
|
if not newAccID:
|
continue
|
# ÔØÈëÐÂÕ˺Å
|
rec[keyName]=newAccID
|
del rec["_id"]
|
colPlayer.update({keyName:accID}, {'$set':rec}, False, False, True, True)
|
cnt += 1
|
print 'table:%s update successfully! cnt=%s changeto %s-%s'%(table, cnt, DBConfig.Spid, DBConfig.Serverid)
|
|
# ÅÅÐаñ
|
# ÐÞ¸ÄÍæ¼Ò±íºÍÕ˺űíÖеÄÍæ¼ÒÕ˺Å
|
colPlayer = db['tagDBBillboard']
|
cnt = 0
|
keyName = "Name2"
|
for rec in colPlayer.find():
|
accID = rec[keyName]
|
|
newAccID = changeAccID(accID, DBConfig.Spid, DBConfig.Serverid)
|
if not newAccID:
|
continue
|
# ÔØÈëÐÂÕ˺Å
|
rec[keyName]=newAccID
|
del rec["_id"]
|
colPlayer.update({keyName:accID, 'Type':rec['Type']}, {'$set':rec}, False, False, True, True)
|
cnt += 1
|
print 'table:tagDBBillboard update successfully! cnt=%s changeto %s-%s'%(cnt, DBConfig.Spid, DBConfig.Serverid)
|
|
|
|
db = con[DBConfig.USER_DB_Log]
|
# ÐÞ¸ÄÍæ¼Ò±íºÍÕ˺űíÖеÄÍæ¼ÒÕ˺Å
|
colPlayer = db['tagDBPlayerInfoLog']
|
cnt = 0
|
for rec in colPlayer.find():
|
accID = rec["AccID"]
|
|
newAccID = changeAccID(accID, DBConfig.Spid, DBConfig.Serverid)
|
if not newAccID:
|
continue
|
# ÔØÈëÐÂÕ˺Å
|
rec['AccID']=newAccID
|
del rec["_id"]
|
colPlayer.update({'AccID':accID}, {'$set':rec}, False, False, True, True)
|
cnt += 1
|
print 'table:tagDBPlayerInfoLog update successfully! cnt=%s changeto %s-%s'%(cnt, DBConfig.Spid, DBConfig.Serverid)
|
|
|
|
con.disconnect()
|
|
|
|
if __name__ == "__main__":
|
main()
|