PyMongo对比Django的MongoEngine [英] PyMongo vs MongoEngine for Django
问题描述
对于我的一个项目,我更喜欢使用 Django + Mongo .
For one of my projects I prefered using Django+Mongo.
为什么我应该使用 MongoEngine ,而不是仅仅使用 PyMongo ?有什么优势?用PyMongo查询得到的结果是所有对象,不是吗?那么MongoEngine的目的是什么?
Why should I use MongoEngine, but not just PyMongo? What are advantages? Querying with PyMongo gives results that are allready objects, aren't they? So what is the purpose of MongoEngine?
推荐答案
我认为您尚未阅读MongoEngine声明.
I assume you have not read the MongoEngine claim.
MongoEngine是一个文档对象 映射器(认为是ORM,但用于文档 数据库)以使用MongoDB 来自Python.
MongoEngine is a Document-Object Mapper (think ORM, but for document databases) for working with MongoDB from Python.
这基本上说明了一切.
此外:您声称Pymongo将交付对象的说法是错误的....在Python中,所有东西都是对象-甚至dict是对象...所以您是对的,但不是自定义类在应用程序级别上定义.
In addition: your claim that Pymongo would deliver objects is wrong....well in Python everything is an object - even a dict is an object...so you are true but not in the sense of having a custom class defined on the application level.
PyMongo是将MongoDB API包装到Python中并提供进出JSON的低级驱动程序.
PyMongo is the low-level driver wrapping the MongoDB API into Python and delivering JSON in and out.
MongoEngine或其他类似MongoKit的图层将基于MongoDB的数据映射到类似于本机Python数据库驱动程序+ SQLAlchemy作为ORM的对象.
MongoEngine or other layers like MongoKit map your MongoDB-based data to objects similar to native Python database drivers + SQLAlchemy as ORM.
这篇关于PyMongo对比Django的MongoEngine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!