def insert_stats(self, stats):
    try:
      with self._cursor() as c:
        ri = stats['run_info']
        try:
          c.execute("""INSERT INTO run_info VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
                    [ri['id'], int(float(ri['timestamp'])), ri['machine'], ri['user'],
                     ri['version'], ri['buildroot'], ri['outcome'], ri['cmd_line']])
        except KeyError as e:
          raise StatsDBError('Failed to insert stats. Key {} not found in RunInfo: {}'.format(
            e.args[0], str(ri)))

        rid = ri['id']
        for table in ['cumulative_timings', 'self_timings']:
          timings = stats[table]
          for timing in timings:
            try:
              c.execute("""INSERT INTO {} VALUES (?, ?, ?)""".format(table),
                        [rid, timing['label'], self._to_ms(timing['timing'])])
            except KeyError as e:
              raise StatsDBError('Failed to insert stats. Key {} not found in timing: {}'.format(
                e.args[0], str(timing)))

    except __HOLE__ as e:
      raise StatsDBError('Failed to insert stats. Key {} not found in stats object.'.format(
        e.args[0]))
dataset/ETHPy150Open pantsbuild/pants/src/python/pants/stats/statsdb.py/StatsDB.insert_stats