<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def reconnect(self, query = None, log_reconnect = False):
 """ Reconnect to the database. """

        uri = list(urisup.uri_help_split(self.sqluri))
        if uri[1]:
            authority   = list(uri[1])
            if authority[1]:
                authority[1] = None
            uri[1]      = authority

        if log_reconnect:
            LOG.warning('reconnecting to %r database (query: %r)', urisup.uri_help_unsplit(uri), query)
        self.__connect()