Exemplo n.º 1
0
import config
import pyDB
import pyCache
from sgLib.core import Gcore
import sgMod.subMod.InterMod as mod_inter

tb_num = 2
limit_cnt = 1000
cnt = 0
curtime = time.time()
send_conn = None
exchange_num = config.EXCHANGE_NUM

BuildingUpCfg = {}
for row in pyDB.out_rows('tb_cfg_building_up'):
    BuildingUpCfg[(row['BuildingType'], row['Level'])] = row

def getCfg(PrimaryKey, field=None):
    '''获取建筑升级配置'''
    row = BuildingUpCfg.get(PrimaryKey)
    if row is None:
        return None
    if not field:
        return row
    if not isinstance(field, basestring):
        raise TypeError, 'argument field should be basesting.'
    return row.get(field)

def ensure_conn(conn):
    '''指定连接获取channel'''
Exemplo n.º 2
0
import pyCache
import config

redis = pyCache.getConn()

server_id = 2#config.SERVER_ID
server_group = config.SERVER_GROUP
limit_cnt = config.LIMIT_COUNT
fields = ['UserId','UserCamp','UserIcon',\
          'UserLevel', 'VipLevel']
cnt = 0

while 1:
    print '第%s次循环' % (cnt+1)
    start, n = cnt * limit_cnt, limit_cnt - 1
    rows = pyDB.out_rows('tb_user', fields, '1 LIMIT %s,%s' % (start, n))

    if len(rows) == 0:
        break

    for row in rows:
        UserId = row.pop('UserId')
        k = 'sgUser.%s.%s' % (UserId, server_id)
        v = row
        redis.set(k, v)
        
        lv = row.pop('UserLevel')
        camp = row.pop('UserCamp')
        k = 'sgGrep.%s.%s.%s.%s.%s' % (server_group, UserId, server_id, lv, camp)
        v = row
        redis.set(k, v)
Exemplo n.º 3
0
import config
import pyDB
import pyCache
from sgLib.core import Gcore
import sgMod.subMod.InterMod as mod_inter

tb_num = 2
limit_cnt = 1000
cnt = 0
curtime = time.time()
send_conn = None
exchange_num = config.EXCHANGE_NUM

BuildingUpCfg = {}
for row in pyDB.out_rows('tb_cfg_building_up'):
    BuildingUpCfg[(row['BuildingType'], row['Level'])] = row


def getCfg(PrimaryKey, field=None):
    '''获取建筑升级配置'''
    row = BuildingUpCfg.get(PrimaryKey)
    if row is None:
        return None
    if not field:
        return row
    if not isinstance(field, basestring):
        raise TypeError, 'argument field should be basesting.'
    return row.get(field)