第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在 python 中使用 pymongo 使用 db.collection.count()

在 python 中使用 pymongo 使用 db.collection.count()

夢(mèng)里花落0921 2023-06-06 17:34:29
我在用著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({})}')
查看完整描述

2 回答

?
臨摹微笑

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊

如文檔中所述

count() 方法已棄用,在事務(wù)中不受支持。請(qǐng)改用 count_documents() 或 estimated_document_count() 。

從 count() 遷移到 count_documents() 時(shí),必須替換以下查詢運(yùn)算符 - $where、$near、$nearSphere

在 3.7 版更改:不推薦使用。

所以使用count_documents


查看完整回答
反對(duì) 回復(fù) 2023-06-06
?
當(dāng)年話下

TA貢獻(xiàn)1890條經(jīng)驗(yàn) 獲得超9個(gè)贊

您收到此警告是因?yàn)?code>pymongo棄用了該count函數(shù),這意味著您不應(yīng)再在新代碼中使用它。

改變你的用途:

db.collection.count({})

db.collection.count_documents({})


查看完整回答
反對(duì) 回復(fù) 2023-06-06
  • 2 回答
  • 0 關(guān)注
  • 369 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)