'Init the connection to the CouchDB server.'

def init(self):

    if (not self.export_enable):
        return None
    if (self.user is None):
        server_uri = 'http://{}:{}/'.format(self.host, self.port)
    else:
        server_uri = 'http://{}:{}@{}:{}/'.format(self.user, self.password, self.host, self.port)
    try:
        s = couchdb.Server(server_uri)
    except Exception as e:
        logger.critical(('Cannot    connect    to    CouchDB    server    %s    (%s)' % (server_uri, e)))
        sys.exit(2)
    else:
        logger.info(('Connected    to    the    CouchDB    server    %s' % server_uri))
    try:
        s[self.db]
    except Exception as e:
        s.create(self.db)
    else:
        logger.info(('There    is    already    a    %s    database' % self.db))
    return s
