This commit is contained in:
wuaho 2021-09-14 12:19:34 +08:00
parent 5a8c4aeecc
commit 6cd1e4fc69
3 changed files with 21 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import os
import sys
from loguru import logger
@ -458,4 +459,17 @@ class ProductionConfig(Config):
}
class DebugConfig(Config):
GAME_MANA_MYSQLDB = {
"host": "127.0.0.1",
"port": 3306,
"user": "root",
"password": "root",
"db": "gamemana"
}
if sys.platform == 'linux':
settings = ProductionConfig()
else:
settings = DebugConfig()

View File

@ -39,8 +39,11 @@ class LoadData(metaclass=abc.ABCMeta):
sql = 'replace into gm_kv set k=%s,v=%s'
async with self.gm_db_pool.acquire() as conn:
async with conn.cursor() as cur:
try:
await cur.execute(sql, (key, value))
await conn.commit()
except Exception as e:
logger.error(e)
@abc.abstractmethod
async def get_data(self):

View File

@ -28,7 +28,7 @@ class LoadUserData(LoadData):
self.last_act_time = await self.get_kv(self.gm_key)
where = {
'logintime': {'$gte': self.last_act_time, '$lt': self.act_time}
'logintime': {'$gte': self.last_act_time-600, '$lt': self.act_time}
}
projection = {
'_id': False,