update db
This commit is contained in:
parent
90c292f35f
commit
67fa9d87b7
@ -18,7 +18,7 @@ pip install flask_cors
|
||||
// 根据依赖文件安装环境
|
||||
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
// 设置全局变量
|
||||
export FLASK_APP=coc.py
|
||||
export FLASK_APP=cherry.py
|
||||
export FLASK_ENV=development
|
||||
// 启动临时服务
|
||||
flask run --host=0.0.0.0 -p 8001
|
||||
|
12
lib/db.py
12
lib/db.py
@ -6,21 +6,21 @@ setting = 'development'
|
||||
|
||||
# 获取数据集
|
||||
def col(arg):
|
||||
conn = MongoClient('mongodb://coc:qlSfefSor5@mongo:27017/coc')
|
||||
conn = MongoClient('mongodb://cherry:fR1jW2xG3bE9@mongo:27017/cherry')
|
||||
if setting == 'development':
|
||||
arg += '_test'
|
||||
elif arg == 'rank':
|
||||
return conn.coc.rank
|
||||
if arg == 'rank':
|
||||
return conn.cherry.rank
|
||||
elif arg == 'rank_test':
|
||||
return conn.coc.rank_test
|
||||
return conn.cherry.rank_test
|
||||
else:
|
||||
return False
|
||||
|
||||
# 向排名表里增加或覆写数据
|
||||
def addRank(nick, count, time):
|
||||
try:
|
||||
# col('rank').update({"cid":cid}, {'$setOnInsert':{"nick":nick}, '$set':{"grade":grade,"time":time}}, {'upsert':'true'})
|
||||
col('rank').insert_one({"count":count,"time":time,"nick":nick})
|
||||
col('rank').update({"cid":cid}, {'$setOnInsert':{"nick":nick}, '$set':{"count":count,"time":time}}, {'upsert':'true'})
|
||||
# col('rank').insert_one({"count":count,"time":time,"nick":nick})
|
||||
except Exception as e:
|
||||
# 失败
|
||||
return {'errcode': 401, 'errmsg': '排名表修改失败'}
|
||||
|
Loading…
x
Reference in New Issue
Block a user