当前位置:网站首页>Pymongo gets a list of data
Pymongo gets a list of data
2022-07-06 06:47:00 【Cute Dai Ma】
At present, there is no way to directly get the whole column of data , Therefore use for Loop data , For example, get all _id:
[i['_id'] for i in coll.find({
}, {
"_id": 1})]
Sample code
from pymongo import MongoClient
import numpy as np
# Specify database
mongo_conn = MongoClient(host='localhost', port=27017)
mongo_db = mongo_conn.get_database("test") # Specify database
coll = mongo_db.get_collection("people")
# Add data
[coll.insert_one({
"num": i, "letter": np.random.choice(a=['a', 'b', 'c', 'd'])}) for i in range(5)]
# Get a column of data :_id
all_num = [i['num'] for i in coll.find({
}, {
"num": 1})] # Get a list of data
print(all_num)
边栏推荐
- Pallet management in SAP SD delivery process
- E-book CHM online CS
- [Yu Yue education] flower cultivation reference materials of Weifang Vocational College
- Office doc add in - Online CS
- Simple query cost estimation
- Wish Dragon Boat Festival is happy
- A method to measure the similarity of time series: from Euclidean distance to DTW and its variants
- 端午节快乐Wish Dragon Boat Festival is happy
- Leetcode daily question (971. flip binary tree to match preorder traversal)
- Data security -- 13 -- data security lifecycle management
猜你喜欢

Bitcoinwin (BCW): 借贷平台Celsius隐瞒亏损3.5万枚ETH 或资不抵债

Every API has its foundation when a building rises from the ground

Phishing & filename inversion & Office remote template

Pallet management in SAP SD delivery process

Changes in the number of words in English papers translated into Chinese

LeetCode每日一题(971. Flip Binary Tree To Match Preorder Traversal)

Is it difficult for girls to learn software testing? The threshold for entry is low, and learning is relatively simple

Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL

Reflex WMS medium level series 3: display shipped replaceable groups
![[ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)](/img/02/41dcdcc6e8f12d76b9c1ef838af97d.png)
[ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)
随机推荐
[unity] how to export FBX in untiy
Fedora/REHL 安装 semanage
机器学习植物叶片识别
How to translate professional papers and write English abstracts better
专业论文翻译,英文摘要如何写比较好
P5706 [deep foundation 2. Example 8] redistributing fat house water -- February 13, 2022
金融德语翻译,北京专业的翻译公司
关于新冠疫情,常用的英文单词、语句有哪些?
成功解决TypeError: data type ‘category‘ not understood
ML之shap:基于adult人口普查收入二分类预测数据集(预测年收入是否超过50k)利用Shap值对XGBoost模型实现可解释性案例之详细攻略
ROS2安装及基础知识介绍
Classification des verbes reconstruits grammaticalement - - English Rabbit Learning notes (2)
MySQL5.72.msi安装失败
[ 英語 ] 語法重塑 之 動詞分類 —— 英語兔學習筆記(2)
论文摘要翻译,多语言纯人工翻译
On the first day of clock in, click to open a surprise, and the switch statement is explained in detail
Apache DolphinScheduler源码分析(超详细)
Use shortcut LNK online CS
查询字段个数
SSO流程分析