{"id":24065,"library":"mongo-ninja-python","title":"Mongo Ninja Python","description":"A Python client for MongoDB that provides a simplified query builder and ORM-like interface. Current version 1.11.1.7, actively maintained with frequent updates.","status":"active","version":"1.11.1.7","language":"python","source_language":"en","source_url":"https://github.com/kissoon/mongo-ninja-python","tags":["mongodb","orm","query-builder","database","pymongo"],"install":[{"cmd":"pip install mongo-ninja-python","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core MongoDB driver dependency","package":"pymongo","optional":false}],"imports":[{"note":"Package name uses underscores, not hyphens","wrong":"from mongo_ninja_python import NinjaClient","symbol":"NinjaClient","correct":"from mongo_ninja import NinjaClient"},{"note":"QueryBuilder is in the query submodule","wrong":"from mongo_ninja import QueryBuilder","symbol":"QueryBuilder","correct":"from mongo_ninja.query import QueryBuilder"}],"quickstart":{"code":"from mongo_ninja import NinjaClient\n\nclient = NinjaClient(uri='mongodb://localhost:27017', db='test')\ncollection = client.collection('users')\nresult = collection.insert_one({'name': 'Alice', 'age': 30})\nprint(result.inserted_id)","lang":"python","description":"Connect to a local MongoDB instance and insert a document into the users collection."},"warnings":[{"fix":"Use `database='...'` instead of `db='...'`.","message":"In v1.11.0, the 'db' parameter was renamed to 'database' in NinjaClient constructor. Old code passing 'db=...' will raise TypeError.","severity":"breaking","affected_versions":">=1.11.0"},{"fix":"Replace `collection.find_one({'name': 'Alice'})` with `collection.find_one(filter={'name': 'Alice'})`.","message":"The `find_one()` method with positional arguments is deprecated. Use keyword arguments for query filters.","severity":"deprecated","affected_versions":">=1.10.0"},{"fix":"Pass `options={'maxPoolSize': 10, 'serverSelectionTimeoutMS': 5000}` to NinjaClient.","message":"Automatic connection pooling may cause stale connections after network interruptions. Configure `maxPoolSize` and `serverSelectionTimeoutMS` explicitly in production.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed: `pip install mongo-ninja-python`. Then import with `from mongo_ninja import NinjaClient`.","cause":"Package is installed as 'mongo-ninja-python' but imported with underscores.","error":"ImportError: No module named 'mongo_ninja'"},{"fix":"Update your code to use `database='your_db_name'` instead of `db='your_db_name'`.","cause":"Breaking change in v1.11.0: parameter renamed from 'db' to 'database'.","error":"TypeError: __init__() got an unexpected keyword argument 'db'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}