Entry 3805

IronPython and MongoDB

   

Submitted by anonymous on May 11, 2010 at 10:47 p.m.
Language: Python. Code size: 496 bytes.

import clr
clr.AddReferenceToFile("MongoDB.Driver.dll")

from MongoDB.Driver import *

def main():
    conn = Mongo("Server=devsrvr")
    conn.Connect()
    
    try:
        db = conn.GetDatabase("test")
        coll = db.GetCollection("things")
        
        query = Document()
        query.Append("lastname", "Waits")
        
        print coll.FindOne(query)
        
    finally:
        conn.Disconnect()
        
        
if __name__ == '__main__':
    main()

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).