How to Use Pymongo and Search for Data
Last modified by Leon Poon on 2021/03/23 13:17
First, set up a virtualenv.
Make sure that your mongo server is running.
In the virtualenv, install pymongo, then try out this .py file in the virtualenv.
from pymongo import MongoClient
client = MongoClient()
db = client['test-database']
collection = db['test-collection']
print(collection.find_one({'my_key': 'some value'}))
client = MongoClient()
db = client['test-database']
collection = db['test-collection']
print(collection.find_one({'my_key': 'some value'}))
If you don't have data yet, you can store some.
You can also follow tutorial.