Skip to content

Instantly share code, notes, and snippets.

@axce1
Created December 16, 2013 16:30
Show Gist options
  • Save axce1/7989908 to your computer and use it in GitHub Desktop.
Save axce1/7989908 to your computer and use it in GitHub Desktop.
create mongoDB
from pymongo import Connection
class MongoDB:
def __init__(self, dbname):
self.conn = Connection('localhost', 27017)
self.db = self.conn[dbname]
def createCollection(self, name=''):
return self.db[name]
if __name__ == '__main__':
database = MongoDB("test")
collection = database.createCollection('testCollection')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment