def run_query(self, db, query):
        try:
            cursor = db.cursor()
            cursor.execute(query)
            metric = {}
            for entry in cursor:
                try:
                    metric[entry[0]] = float(entry[1])
                except ValueError as e:
                    metric[entry[0]] = entry[1]

            return metric
        except MySQLdb.OperationalError as message:
            self.checks_logger.debug(
                'mysql: MySQL query error when getting metrics = '.format(
                    message)
                )
Run a query and returns a dictionary with results
dataset/ETHPy150Open serverdensity/sd-agent-plugins/MySQL/MySQL.py/MySQL.run_query