Motor 0.3.2 released, MongoDB Python Drive

Source: Internet
Author: User
Keywords nbsp posted Torn dler

Motor 0.3.2 Released, this version compatible http://www.aliyun.com/zixun/aggregation/13461.html ">mongodb 2.2,2.4 and 2.6, minimum requirements Pymongo 2.7.1.

This release fixes the socket leaks in the "copy_database" method and rewrites the problems and bugs in "Let Us Now Praise Resourcewarnings".

Get the latest version: Pip Install--upgrade motor. See here for more information.

Motor provides a Tornado MongoDB driver based on callback and Future mechanism. Motor encapsulated Pymongo

Installation: $ pip Install motor

Sample code:

? 123456789101112131415161718192021222324252627282930313233from tornado import gen   Class  newmessagehandler (Tornado.web.RequestHandler):     @tornado. web.asynchronous     @ Gen.coroutine     Def post (self):         "" "Insert a message." "         msg = self.get_argument (' msg ')         db =  self.settings[' DB ']            # insert ()  returns a Future.  Yield the future to get the result.         Result = yield db.messages.insert ({' msg ':  msg})            # success         self.redirect ('/')      class  Messageshandler (Tornado.web.RequestHandler):     @tornado. web.asynchronous     @gen. coroutine     Def get (self): &NBsp;       "" "Display all messages." "         self.write (' <a href= "/compose" >compose a message</a><br > ')         self.write (' <ul> ')         db = self.settings[' DB ']         Cursor = db.messages.find () sort ([(' _id ',  -1)])         while  (Yield cursor.fetch_next):             message =  Cursor.next_object ()             self.write (' <li>%s</li> '  %  message[' msg ']            # iteration complete         Self.write (' </ul> ')         Self.finish ()

Motor API

Motorclient–connection to MongoDB

Motorreplicasetclient–connection to MongoDB replica set

Motordatabase

Motorcollection

Motorcursor

Motor Gridfs Classes

Motor.web

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.