參考資料:http://www.tuicool.com/articles/bMvI7vNmongodb
from mongoengine import * from datetime import datetime connect('PornHub', host='mongodb://192.168.111.129:27017') # 定義分類文檔 class Categories(Document): ' 繼承Document類,爲普通文檔 ' name = StringField(max_length=30, required=True) artnum = IntField(default=0, required=True) date = DateTimeField(default=datetime.now(), required=True) cate = Categories.objects.all() for c in cate: print(c.name)
https://segmentfault.com/q/1010000005143219segmentfault