Specify a boolean string converter for MySQLdb. Some older versions of MySQLdb do not include this, and it breaks monitor_db.
Many thanks to Peter Pouliot for lots of help and patience in tracking down this problem.
Signed-off-by: Steve Howard <showard@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1342 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/scheduler/monitor_db b/scheduler/monitor_db
index a05b6e5..f8c2190 100755
--- a/scheduler/monitor_db
+++ b/scheduler/monitor_db
@@ -147,9 +147,19 @@
self.conn = None
self.cur = None
+ import MySQLdb.converters
+ self.convert_dict = MySQLdb.converters.conversions
+ self.convert_dict.setdefault(bool, self.convert_boolean)
+
self.connect()
+ @staticmethod
+ def convert_boolean(boolean, conversion_dict):
+ 'Convert booleans to integer strings'
+ return str(int(boolean))
+
+
def connect(self):
self.disconnect()
@@ -168,10 +178,9 @@
while not self.conn:
try:
- self.conn = MySQLdb.connect(host=DB_HOST,
- user=DB_USER,
- passwd=DB_PASS,
- db=DB_SCHEMA)
+ self.conn = MySQLdb.connect(
+ host=DB_HOST, user=DB_USER, passwd=DB_PASS,
+ db=DB_SCHEMA, conv=self.convert_dict)
self.conn.autocommit(True)
self.cur = self.conn.cursor()