Use rowcount rather than exceptions on fetchone()[]

Change-Id: Ibc844f7e32786182ea33a7a658b751525fd13f95
diff --git a/db/db.py b/db/db.py
index b19b616..c3a9f86 100644
--- a/db/db.py
+++ b/db/db.py
@@ -165,10 +165,9 @@
         data = (value, )
         self.cursor.execute(sql, data)
 
-        try:
-            result = self.cursor.fetchone()[0]
-            return result
-        except TypeError:
+        if self.cursor.rowcount > 0:
+            return self.cursor.fetchone()[0]
+        else:
             return None
 
     def get_switch_id(self, name):