[autotest] In tko/parse, fix TypeError in MySQLdb query

In the MySQLdb library (interacting with MySQL), parametrized queries
inserting an inf float value converts to an inf identifier, causing an
Unknown column error.

BUG=chromium:660111
TEST=Recreate conditions and test fix in local Python/MySQL shell

Change-Id: Ie7d471eb8d26b3cd838951500907f4e2bf3b203f
Reviewed-on: https://chromium-review.googlesource.com/407924
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
diff --git a/tko/db.py b/tko/db.py
index a70774d..450c40a 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -2,7 +2,12 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import re, os, sys, time, random
+import math
+import os
+import random
+import re
+import sys
+import time
 
 import common
 from autotest_lib.client.common_lib import global_config
@@ -529,7 +534,10 @@
                             commit=commit)
             for key, value in i.perf_keyval.iteritems():
                 data['attribute'] = key
-                data['value'] = value
+                if math.isnan(value) or math.isinf(value):
+                    data['value'] = None
+                else:
+                    data['value'] = value
                 self.insert('tko_iteration_result', data,
                             commit=commit)