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

26 lines
545 B
Python
Raw Normal View History

"""
Mongo_tfse
"""
import pymongo
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))
2022-02-23 16:48:30 +08:00
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)