mongodb(三):数据库连接(python)

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

 

mongodb(三):数据库连接(python)

上一篇:excel转成sql


下一篇:MySQL同步故障:" Slave_SQL_Running:No" 主从同步的从表进行了写操作