'Connect to the MongoDB server.'

def _get_connection(self):

    if (self._connection is None):
        from pymongo import MongoClient
        host = self.mongo_host
        if (not host):
            host = self.host
            if (isinstance(host, string_t) and (not host.startswith(u'mongodb://'))):
                host = u'mongodb://{0}:{1}'.format(host, self.port)
        conf = dict(self.options)
        conf[u'host'] = host
        self._connection = MongoClient(**conf)
    return self._connection
