mongoengine

A Python Document-Object Mapper for working with MongoDB
Download

mongoengine Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Harry Marr
  • Publisher web site:
  • http://hmarr.com/

mongoengine Tags


mongoengine Description

A Python Document-Object Mapper for working with MongoDB MongoEngine is a Python Object-Document Mapper for working with MongoDB. Documentation available at http://hmarr.com/mongoengine/ - there is currently a tutorial, a user guide and an API reference.Installation:If you have setuptools you can use easy_install mongoengine. Otherwise, you can download the source from GitHub and run python setup.py install.Examples:Some simple examples of what MongoEngine code looks like:class BlogPost(Document): title = StringField(required=True, max_length=200) posted = DateTimeField(default=datetime.datetime.now) tags = ListField(StringField(max_length=50))class TextPost(BlogPost): content = StringField(required=True)class LinkPost(BlogPost): url = StringField(required=True)# Create a text-based post>>> post1 = TextPost(title='Using MongoEngine', content='See the tutorial')>>> post1.tags = >>> post1.save()# Create a link-based post>>> post2 = LinkPost(title='MongoEngine Docs', url='hmarr.com/mongoengine')>>> post2.tags = >>> post2.save()# Iterate over all posts using the BlogPost superclass>>> for post in BlogPost.objects:... print '===', post.title, '==='... if isinstance(post, TextPost):... print post.content... elif isinstance(post, LinkPost):... print 'Link:', post.url... print...=== Using MongoEngine ===See the tutorial=== MongoEngine Docs ===Link: hmarr.com/mongoengine>>> len(BlogPost.objects)2>>> len(HtmlPost.objects)1>>> len(LinkPost.objects)1# Find tagged posts>>> len(BlogPost.objects(tags='mongoengine'))2>>> len(BlogPost.objects(tags='mongodb'))1 Requirements: · Python · pymongo · Sphinx


mongoengine Related Software