Now I am working on a simple search engine , Use the news data of today's headlines as the data source . These data are non structural , It's more suitable for MongoDB To store .
The following is a simple example .
#!/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()