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

27 lines
544 B
Python

"""
Mongo_tfse
"""
import pymongo
DB_HOST = '116.63.130.34'
DB_USER = 'root'
DB_PASS = 'sromitdTW569kC#M'
DB_PORT = 27018
client = pymongo.MongoClient('mongodb://{}:{}@{}:{}'.format(DB_USER, DB_PASS, DB_HOST, DB_PORT))
def update_data(db, table, find, data):
"""
保存数据
Parameters:
db: str 数据库
table: str 表
find: dict 查询条件
data: dict 更新数据
Returns:
-
"""
collection = client[db][table]
collection.update_one(find, {"$set": data}, upsert=True)