时间:2010-07-24 14:42:30

标签: python django mongodb pymongo mongoengine

2 个答案:

答案 0 :(得分:12)

pymongo的例子:

import pymongo

mongo = pymongo.Connection('localhost')
collection = mongo['database']['hosts']
collection.ensure_index('host_name', unique=True)

答案 1 :(得分:8)