26 lines
545 B
Python
26 lines
545 B
Python
"""
|
|
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))
|
|
|
|
|
|
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) |