2022-01-21 16:50:26 +08:00
|
|
|
"""
|
|
|
|
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))
|
|
|
|
|
|
|
|
|
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)
|