|
|
|
@ -196,10 +196,11 @@ def mongdbClientS(): |
|
|
|
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') |
|
|
|
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') |
|
|
|
|
|
|
|
|
|
|
|
if auth == 'disabled': |
|
|
|
if auth == 'disabled': |
|
|
|
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True) |
|
|
|
client = pymongo.MongoClient(host=ip, port=int(port)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
# print(auth,mg_root) |
|
|
|
# print(auth,mg_root) |
|
|
|
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root) |
|
|
|
# 使用 admin 数据库进行认证,兼容 MongoDB 3.0 |
|
|
|
|
|
|
|
client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin') |
|
|
|
return client |
|
|
|
return client |
|
|
|
|
|
|
|
|
|
|
|
def mongdbClient(): |
|
|
|
def mongdbClient(): |
|
|
|
@ -210,11 +211,12 @@ def mongdbClient(): |
|
|
|
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') |
|
|
|
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') |
|
|
|
# print(ip,port,auth,mg_root) |
|
|
|
# print(ip,port,auth,mg_root) |
|
|
|
if auth == 'disabled': |
|
|
|
if auth == 'disabled': |
|
|
|
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True) |
|
|
|
client = pymongo.MongoClient(host=ip, port=int(port)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
# uri = "mongodb://root:"+mg_root+"@127.0.0.1:"+str(port) |
|
|
|
# uri = "mongodb://root:"+mg_root+"@127.0.0.1:"+str(port) |
|
|
|
# client = pymongo.MongoClient(uri) |
|
|
|
# client = pymongo.MongoClient(uri) |
|
|
|
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root) |
|
|
|
# 使用 admin 数据库进行认证,兼容 MongoDB 3.0 |
|
|
|
|
|
|
|
client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin') |
|
|
|
return client |
|
|
|
return client |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|