Index: trunk/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- trunk/ippToPsps/jython/ipptopspsdb.py	(revision 33559)
+++ trunk/ippToPsps/jython/ipptopspsdb.py	(revision 33560)
@@ -736,5 +736,15 @@
 
     '''
-    Sets the value for a given column in the clients table
+    Sets the config field for a set of loader clients
+    '''
+    def setConfigForLoaders(self, config, ids):
+
+        for id in ids:
+            self.execute("UPDATE clients SET config = '" + config + "' \
+                    WHERE type = 'loader.py' \
+                    AND id = " + str(id))
+
+    '''
+    Sets the value for a given column for a set of loader clients
     '''
     def setColForLoaders(self, col, bool, ids):
@@ -809,5 +819,55 @@
 
     '''
-    Populates Config object
+    Returns a list of available configs
+    '''
+    def getConfigList(self):
+        
+        sql = "SELECT DISTINCT name FROM config"
+
+        configs = []
+        try:
+            rs = self.executeQuery(sql)
+            while (rs.next()): configs.append(rs.getString(1))
+        except:
+            self.logger.errorPair("Can't get config names", sql)
+        finally:
+            rs.close()
+
+        return configs
+
+
+    '''
+    Writes current Config object to Db
+    '''
+    def writeConfig(self):
+
+        sql = "UPDATE config \
+               SET \
+               datastore_product = '" + self.config.datastoreProduct + "' \
+               ,datastore_type = '" + self.config.datastoreType + "' \
+               ,datastore_publish = " + self.config.datastorePublishing + " \
+               ,dvo_label = '" + self.config.dvoLabel + "' \
+               ,dvo_location = '" + self.config.dvoLocation + "' \
+               ,min_ra = " + self.config.minRa + " \
+               ,max_ra = " + self.config.maxRa + " \
+               ,min_dec = " + self.config.minDec + " \
+               ,max_dec = " + self.config.maxDec + " \
+               ,box_size = " + self.config.boxSize + " \
+               ,base_path = '" + self.config.basePath + "' \
+               ,data_release = " + self.config.dataRelease + " \
+               ,delete_local = " + self.config.deleteLocal + " \
+               ,delete_datastore = " + self.config.deleteDatastore + " \
+               ,delete_dxlayer = " + self.config.deleteDxLayer + " \
+               ,epoch = '" + self.config.epoch + "' \
+               ,survey = '" + self.config.survey + "' \
+               ,psps_survey = '" + self.config.pspsSurvey + "' \
+               ,queue_P2 = " + self.config.queuingThisBatchType("P2") + " \
+               ,queue_ST = " + self.config.queuingThisBatchType("ST") + " \
+               WHERE name = '" + self.config.name + "'"
+
+        self.execute(sql) 
+
+    '''
+    Reads config from the database and populates Config object
     '''
     def readConfig(self, host, pid):
@@ -830,24 +890,24 @@
         # now load that config
         sql = "SELECT \
-        datastore_product, \
-        datastore_type, \
-        datastore_publish, \
-        dvo_label, \
-        dvo_location, \
-        min_ra, \
-        max_ra, \
-        min_dec, \
-        max_dec, \
-        box_size, \
-        base_path, \
-        data_release, \
-        delete_local, \
-        delete_datastore, \
-        delete_dxlayer, \
-        epoch, \
-        survey, \
-        psps_survey, \
-        queue_P2, \
-        queue_ST \
+        datastore_product \
+        ,datastore_type \
+        ,datastore_publish \
+        ,dvo_label \
+        ,dvo_location \
+        ,min_ra \
+        ,max_ra \
+        ,min_dec \
+        ,max_dec \
+        ,box_size \
+        ,base_path \
+        ,data_release \
+        ,delete_local \
+        ,delete_datastore \
+        ,delete_dxlayer \
+        ,epoch \
+        ,survey \
+        ,psps_survey \
+        ,queue_P2 \
+        ,queue_ST \
         FROM config \
         WHERE name = '" + self.config.name + "'"
@@ -1222,4 +1282,10 @@
 
     '''
+    Purges old clients that may have die, i.e. those with a timestamp older than n hours
+    '''
+    def purgeDeadClients(self):
+        self.execute("DELETE FROM clients WHERE timestamp <  now() -  INTERVAL 6 HOUR")
+
+    '''
     Destructor
     '''
