tfse-model-api-v0.2/Rating/db.py

36 lines
779 B
Python
Raw Normal View History

2021-12-07 15:28:49 +08:00
"""
Mongo_tfse
"""
import pymongo
client = pymongo.MongoClient('mongodb://{}:{}@{}:{}'.format('root', 'sromitdTW569kC#M', '116.63.130.34', 27018))
2021-12-07 15:28:49 +08:00
def find_threshold(param):
"""
根据行业查询阈值
Parameters:
2021-12-15 00:17:04 +08:00
param: str 二级行业
2021-12-07 15:28:49 +08:00
Returns:
2021-12-15 00:17:04 +08:00
data 查询结果
2021-12-07 15:28:49 +08:00
"""
collection = client['模型']['财务指标阈值']
data = collection.find({"二级行业": param}, {'_id': False})
return list(data)
2021-12-15 00:17:04 +08:00
def update_data(db, table, find, data):
"""
保存数据
Parameters:
2021-12-15 00:17:04 +08:00
db: str 数据库
table: str
find: dict 查询条件
data: dict 更新数据
Returns:
2021-12-15 00:17:04 +08:00
-
"""
2021-12-15 00:17:04 +08:00
collection = client[db][table]
collection.update_one(find, {"$set": data}, upsert=True)