pymongo helper
import pymongo import click # 数据库基本信息 db_configs = { 'type': 'mongo', 'host': '127.0.0.1', 'port': '27017', "user": "", "password": "", 'db_name': 'mafengwo' } class Mongo(): def __init__(self): self.db_name = db_configs.get("db_name") self.host = db_configs.get("host") self.port = db_configs.get("port") self.client = pymongo.MongoClient(f'mongodb://{self.host}:{self.port}', connect=False, maxPoolSize=10) self.username = db_configs.get("user") self.password = db_configs.get("passwd") if self.username and self.password: self.db = self.client[self.db_name].authenticate(self.username, self