2021-12-07 15:28:49 +08:00
|
|
|
"""
|
|
|
|
Mongo_tfse
|
|
|
|
"""
|
|
|
|
|
|
|
|
import pymongo
|
|
|
|
|
2022-03-23 14:38:56 +08:00
|
|
|
DB_HOST = "116.63.130.34"
|
|
|
|
DB_PASS = "UTlC9cCoglD1cI1*"
|
|
|
|
DB_USER = "root"
|
|
|
|
DB_PORT = "27021"
|
|
|
|
client = pymongo.MongoClient('mongodb://{}:{}@{}:{}'.format(DB_USER, DB_PASS, DB_HOST, DB_PORT))
|
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
|
|
|
"""
|
2022-03-23 14:38:56 +08:00
|
|
|
collection = client['模型端']['综信评价财指阈值']
|
2021-12-07 15:28:49 +08:00
|
|
|
data = collection.find({"二级行业": param}, {'_id': False})
|
|
|
|
return list(data)
|
|
|
|
|
|
|
|
|
2021-12-15 00:17:04 +08:00
|
|
|
def update_data(db, table, find, data):
|
2021-12-10 15:52:38 +08:00
|
|
|
"""
|
|
|
|
保存数据
|
|
|
|
Parameters:
|
2021-12-15 00:17:04 +08:00
|
|
|
db: str 数据库
|
|
|
|
table: str 表
|
|
|
|
find: dict 查询条件
|
|
|
|
data: dict 更新数据
|
2021-12-10 15:52:38 +08:00
|
|
|
Returns:
|
2021-12-15 00:17:04 +08:00
|
|
|
-
|
2021-12-10 15:52:38 +08:00
|
|
|
"""
|
2021-12-15 00:17:04 +08:00
|
|
|
collection = client[db][table]
|
|
|
|
collection.update_one(find, {"$set": data}, upsert=True)
|