import pymongo
from pymongo import MongoClient
client = MongoClient()
client = MongoClient('localhost', 27017)
db = client['test-database']
import datetime
post = {"author": "Mike",
"text": "My first blog post!",
"tags": ["mongodb", "python", "pymongo"],
"date": datetime.datetime.utcnow()}
posts = db.posts
post_id = posts.insert_one(post).inserted_id
for item in db.posts.find({},{ "_id": 0, "author": 1}):
print(item)
Из этого https://www.w3schools.com/python/python_mongodb_find.asp, Мы можем выбрать любые поля.
"_id" : 0, # not select '_id' field
"author" : 1 # select 'author' field