我在用著MongoDB shell version v4.4.0 和 pymongo 3.10.0版本當(dāng)我使用any_db.any_collection.count()或any_db.any_collection.count({})在控制臺(tái)中顯示警告DeprecationWarning: count is deprecated. Use estimated_document_count or count_documents instead. Please note that $where must be replaced by $expr, $near must be replaced by $geoWithin with $center, and $nearSphere must be replaced by $geoWithin with $centerSphere print(f'Total Categories = {db.rank_list_category.count({})}') 我的代碼:import pandas as pdfrom src.utils import get_full_pathfrom pymongo import MongoClientfrom bson.objectid import ObjectIdclient = MongoClient('localhost', 27017)db = client['techexpert']print(f'Total Categories = {db["rank_list_category"].count({})}')輸出:Total Categories = 5 /home/mobin/PycharmProjects/IMDb/src/database/database_service_provider.py:17: DeprecationWarning: count is deprecated. Use estimated_document_count or count_documents instead. Please note that $where must be replaced by $expr, $near must be replaced by $geoWithin with $center, and $nearSphere must be replaced by $geoWithin with $centerSphere print(f'Total Categories = {db.rank_list_category.count({})}')
在 python 中使用 pymongo 使用 db.collection.count()
夢(mèng)里花落0921
2023-06-06 17:34:29
