import pymongo
def get_mongodb_conn(**kwargs):
db_host = kwargs.get('host')
db_port = kwargs.get('port')
db_name = kwargs.get('db_name',settings['MONGODB_DBNAME'])
mongo_client = pymongo.MongoClient(host = db_host,port = db_port)#连接mongodb
mongo_db = mongo_client[db_name]#连接一个库 return mongo_db