For a project , I'm currently running a local MongoDB instance without authentication.
I connect to the database in python using pymongo. For most use cases, I'll only want to run read queries. I'd like to specify a read-only pymongo.MongoClient
connection, so I can avoid accidental write operations, which could mess up the database.
There is an existing related question that is in the context of replicas. In my case, there is a single node running in Docker. I also looked through the read preference docs .
The only way to prevent accidentally modifying your MongoDB data is by enabling authentication. PyMongo and other drivers do not have a feature that can accomplish this goal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.