Skip to content

Instantly share code, notes, and snippets.

@jaychoo
Created September 27, 2011 20:29
Show Gist options
  • Save jaychoo/1246146 to your computer and use it in GitHub Desktop.
Save jaychoo/1246146 to your computer and use it in GitHub Desktop.
Use MongoDB connection in singleton style
from pymongo import Connection
class MongoCon(object):
__db = None
@classmethod
def get_connection(cls):
if cls.__db is None:
cls.__db = Connection()
return cls.__db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment