find operation on tables
authorScott Baker <bakers@cs.arizona.edu>
Sat, 27 Sep 2008 00:51:20 +0000 (00:51 +0000)
committerScott Baker <bakers@cs.arizona.edu>
Sat, 27 Sep 2008 00:51:20 +0000 (00:51 +0000)
util/genitable.py
util/record.py

index 53756aa..53b69c6 100644 (file)
@@ -72,8 +72,8 @@ class GeniTable():
         #print query_str
         self.cnx.query(query_str)
 
-    def resolve_dict(self, type, hrn):
-        query_str = "SELECT * FROM " + self.tablename + " WHERE name = '" + hrn + "'"
+    def find_dict(self, type, value, searchfield):
+        query_str = "SELECT * FROM " + self.tablename + " WHERE " + searchfield + " = '" + str(value) + "'"
         dict_list = self.cnx.query(query_str).dictresult()
         result_dict_list = []
         for dict in dict_list:
@@ -81,13 +81,19 @@ class GeniTable():
                result_dict_list.append(dict)
         return result_dict_list
 
-    def resolve(self, type, hrn):
-        result_dict_list = self.resolve_dict(type, hrn)
+    def find(self, type, value, searchfield):
+        result_dict_list = self.find_dict(type, value, searchfield)
         result_rec_list = []
         for dict in result_dict_list:
             result_rec_list.append(GeniRecord(dict=dict))
         return result_rec_list
 
+    def resolve_dict(self, type, hrn):
+        return self.find_dict(type, hrn, "name")
+
+    def resolve(self, type, hrn):
+        return self.find(type, hrn, "name")
+
     def list_dict(self):
         query_str = "SELECT * FROM " + self.tablename
         result_dict_list = self.cnx.query(query_str).dictresult()
index bf9156c..049df25 100644 (file)
@@ -5,6 +5,7 @@
 # TODO: Use existing PLC database methods? or keep this separate?
 
 import report
+from gid import *
 
 # Record is a tuple (Name, GID, Type, Info)
 #    info is comprised of the following sub-fields