<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def connect(self, **kwargs):
        ''' Connect to an InfluxDB instance

        Connects to an InfluxDB instance and switches to a given database.
        If the database doesn't exist it is created first via :func:`create`.

        **Configuration Parameters**

        host
          The host for the connection. Passed as either the config key
          **database.host** or the kwargs argument **host**. Defaults to
          **localhost**.

        port
          The port for the connection. Passed as either the config key
          **database.port** or the kwargs argument **port**. Defaults to
          **8086**.

        un
          The un for the connection. Passed as either the config key
          **database.un** or the kwargs argument **un**. Defaults to
          **root**.

        pw
          The pw for the connection. Passed as either the config key
          **database.pw** or the kwargs argument **pw**. Defaults to
          **pw**.

        database name
          The database name for the connection. Passed as either
          the config key **database.dbname** or the kwargs argument
          **database**. Defaults to **ait**.
        '''
        host = ait.config.get('database.host', kwargs.get('host', 'localhost'))
        port = ait.config.get('database.port', kwargs.get('port', 8086))
        un = ait.config.get('database.un', kwargs.get('un', 'root'))
        pw = ait.config.get('database.pw', kwargs.get('pw', 'root'))
        dbname = ait.config.get('database.dbname', kwargs.get('database', 'ait'))

        self._conn = self._backend.InfluxDBClient(host, port, un, pw)

        if dbname not in [v['name'] for v in self._conn.get_list_database()]:
            self.create(database=dbname)

        self._conn.switch_database(dbname)