Created
September 27, 2011 20:29
-
-
Save jaychoo/1246146 to your computer and use it in GitHub Desktop.
Use MongoDB connection in singleton style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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