0
pymongo 2.8을 사용하여 MongoDB에 사용자를 추가하는 Python 스크립트를 작성하려고합니다.pymongo 2.8 - admin db에 중복 사용자 삽입을 피하는 방법
2017-01-06T17:29:59.209-0500 E QUERY [thread1] Error: couldn't add user: User "[email protected]" already exists
: 나는 동일한 코드를 여러 번 실행하면 우리가 중복 된 사용자를 삽입 할 때 우리는 몽고 쉘에서 보는 것처럼이 오류가 표시되지
db = conn['test123']
collection=db['testing']
db1 = conn['admin']
try:
data = db1.add_user('test123user', 'test123pass', roles=[{'role':'readWrite','db':'test123'}])
print("Database with user is created")
except Exception as e:
print("error: Unable to create the user for database ")
raise
: 여기 내 코드입니다
pymomgo를 통해 중복 사용자를 삽입하지 않으려면 어떻게해야합니까? 감사! 사용자 이름이 이미 존재하는 경우