aboutsummaryrefslogtreecommitdiff
path: root/databases/mongo/admins.py
blob: e844cbcd43e06463444cc496dc1dd0992223c9df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from pymongo import MongoClient

# Connect to the MongoDB server
client = MongoClient("mongodb://localhost:27017/")

# Select the 'admin' database
db = client.admin

# Query the 'system.users' collection
users = db.system.users.find(
    {}, {"user": 1, "db": 1, "roles": 1, "credentials": 1, "userSource": 1}
)

# Print the results in a pretty format
for user in users:
    print(user)