Skip to content

Instantly share code, notes, and snippets.

@gtcarlos
Created February 1, 2013 01:19
Show Gist options
  • Save gtcarlos/4688363 to your computer and use it in GitHub Desktop.
Save gtcarlos/4688363 to your computer and use it in GitHub Desktop.
Python code to connect to the database MongoDB and select first one.
import pymongo
from pymongo import Connection
connection = Connection('localhost', 27017)
db = connection.test
names = db.names
item = names.find_one()
print item['name']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment