docs: def WriteClientSnapshotHistory(self, clients, cursor=None):
      """Writes the full history for a particular client."""
      client_id = clients[0].client_id
      latest_timestamp = max(client.timestamp for client in clients)
  
      query = ""
      params = {
          "client_id": db_utils.ClientIDToInt(client_id),
          "latest_timestamp": mysql_utils.RDFDatetimeToTimestamp(latest_timestamp)
      }
  
      for idx, client in enumerate(clients):
        startup_info = client.startup_info
        client.startup_info = None
  
        query += """
        INSERT INTO client_snapshot_history (client_id, timestamp,
                                             client_snapshot)
        VALUES (%(client_id)s, FROM_UNIXTIME(%(timestamp_{idx})s),
                %(client_snapshot_{idx})s);
  
        INSERT INTO client_startup_history (client_id, timestamp,
                                            startup_info)
        VALUES (%(client_id)s, FROM_UNIXTIME(%(timestamp_{idx})s),
                %(startup_info_{idx})s);
        """.format(idx=idx)
  
        params.update({
            "timestamp_{idx}".format(idx=idx):
                mysql_utils.RDFDatetimeToTimestamp(client.timestamp),
            "client_snapshot_{idx}".format(idx=idx):
                client.SerializeToString(),
            "startup_info_{idx}".format(idx=idx):
                startup_info.SerializeToString(),
        })
  
        client.startup_info = startup_info
  
      query += """
      UPDATE clients
         SET last_snapshot_timestamp = FROM_UNIXTIME(%(latest_timestamp)s)
       WHERE client_id = %(client_id)s
         AND (last_snapshot_timestamp IS NULL OR
              last_snapshot_timestamp < FROM_UNIXTIME(%(latest_timestamp)s));
  
      UPDATE clients
         SET last_startup_timestamp = FROM_UNIXTIME(%(latest_timestamp)s)
       WHERE client_id = %(client_id)s
         AND (last_startup_timestamp IS NULL OR
              last_startup_timestamp < FROM_UNIXTIME(%(latest_timestamp)s));
      """
  
      try:
        cursor.execute(query, params)
      except MySQLdb.IntegrityError as error:
        raise db.UnknownClientError(client_id, cause=error)