Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

26 lines (15 sloc) 0.483 kb
__version__ = '1.3.0'
from billy.conf import settings
class LazyDb(object):
def __init__(self):
self._db = None
def __getattr__(self, attr):
if not self._db:
import pymongo
host = settings.MONGO_HOST
port = settings.MONGO_PORT
db_name = settings.MONGO_DATABASE
conn = pymongo.Connection(host, port)
self._db = conn[db_name]
return getattr(self._db, attr)
db = LazyDb()
Jump to Line
Something went wrong with that request. Please try again.