Now I am building a simple search engine, using the news data of Toutiao as the data source. These data are unstructured and are more suitable for storage in MongoDB.
The following is a simple example of use.
#!/usr/bin/python # -*- coding:utf-8 -*- import pymongo class documentManager(object): def __init__(self): pass def connect_mongo(self): client = pymongo.Connection("127.0.0.1",27017) db = client.data_db collection = db.data_collection mydict = {"name":"Lucy", "sex":"female","job":"nurse"} collection.insert(mydict) for i in collection.find({"name":"Lucy"}): print i if __name__ == '__main__': manager = documentManager() manager.connect_mongo()