Added trivial self-test if run directly

Just dump the contents of the current database

Change-Id: I7e1c250d45a2dea8d188951f36cac4892f42f2ed
diff --git a/db/db.py b/db/db.py
index 378dc35..7b1d010 100644
--- a/db/db.py
+++ b/db/db.py
@@ -20,7 +20,13 @@
 
 import psycopg2
 import psycopg2.extras
-import datetime
+import datetime, os, sys
+
+if __name__ == '__main__':
+    vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
+    sys.path.insert(0, vlandpath)
+    sys.path.insert(0, "%s/.." % vlandpath)
+
 from errors import CriticalError, InputError
 
 class VlanDB:
@@ -540,3 +546,16 @@
     def all_vlans(self):
         return self._dump_table("vlan")
 
+if __name__ == '__main__':
+    db = VlanDB()
+    switches = db.all_switches()
+    print 'The DB knows about %d switch(es)' % len(switches)
+    print switches
+    ports = db.all_ports()
+    print 'The DB knows about %d port(s)' % len(ports)
+    print ports
+    vlans = db.all_vlans()
+    print 'The DB knows about %d vlan(s)' % len(vlans)
+    print vlans
+
+