Extract data from database

def _datalog(self, parameter, run, maxrun, det_id):
        "Extract data from database"
        values = {
            'parameter_name': parameter,
            'minrun': run,
            'maxrun': maxrun,
            'detid': det_id,
        }
        data = urlencode(values)
        content = self._get_content('streamds/datalognumbers.txt?' + data)
        if content.startswith('ERROR'):
            log.error(content)
            return None
        try:
            dataframe = read_csv(content)
        except ValueError:
            log.warning(
                "Empty dataset"
            )    # ...probably. Waiting for more info
            return make_empty_dataset()
        else:
            add_datetime(dataframe)
            try:
                self._add_converted_units(dataframe, parameter)
            except KeyError:
                log.warning(
                    "Could not add converted units for {0}".format(parameter)
                )
            return dataframe