Change API for _get_element to avoid exceptions

If we don't have any entries for a given query, return None instead

Change-Id: I41494cee87f2d2b5e3ce90584361b520c159a85d
diff --git a/db/db.py b/db/db.py
index 55baee3..026a0b9 100644
--- a/db/db.py
+++ b/db/db.py
@@ -162,9 +162,11 @@
         data = (value, )
         self.cursor.execute(sql, data)
 
-        # Will raise an exception here if there are no rows that
-        # match. That's OK - the caller needs to deal with that.
-        return self.cursor.fetchone()[0]
+        try:
+            result = self.cursor.fetchone()[0]
+            return result
+        except TypeError:
+            return None
 
     def get_switch_id(self, name):
         return self._get_element("switch_id", "switch", "name", name)