gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 36238 - in gump/trunk/python/gump: mysql stats/mysql utils
Date Wed, 11 Aug 2004 18:16:45 GMT
Author: ajack
Date: Wed Aug 11 11:16:45 2004
New Revision: 36238

Modified:
   gump/trunk/python/gump/mysql/databaser.py
   gump/trunk/python/gump/stats/mysql/statsdb.py
   gump/trunk/python/gump/utils/mysql.py
Log:
Allow the database to be configurable (within the SQL).

Modified: gump/trunk/python/gump/mysql/databaser.py
==============================================================================
--- gump/trunk/python/gump/mysql/databaser.py	(original)
+++ gump/trunk/python/gump/mysql/databaser.py	Wed Aug 11 11:16:45 2004
@@ -33,6 +33,7 @@
     
     def __init__(self,run):              
         gump.run.actor.AbstractRunActor.__init__(self,run)    
+        self.dbInfo=self.workspace.getDatabaseInformation()
         
     def processOtherEvent(self,event):   
         pass
@@ -51,7 +52,7 @@
         helper=None
         try:
             conn=self.getConnected()
-            helper=gump.utils.mysql.DbHelper(conn)
+            helper=gump.utils.mysql.DbHelper(conn,self.dbInfo.getDatabase())
             
             # Prepare the data
             settings = {}
@@ -106,13 +107,12 @@
         """
         Get a database connection.
         """
-        dbInfo=self.workspace.getDatabaseInformation()
                 
         return MySQLdb.Connect(
-                    host=dbInfo.getHost(), 
-                    user=dbInfo.getUser(),
-                    passwd=dbInfo.getPasswd(), 
-                    db=dbInfo.getDatabase(),
+                    host=self.dbInfo.getHost(), 
+                    user=self.dbInfo.getUser(),
+                    passwd=self.dbInfo.getPasswd(), 
+                    db=self.dbInfo.getDatabase(),
                     compress=1,
                     cursorclass=MySQLdb.cursors.DictCursor)
         

Modified: gump/trunk/python/gump/stats/mysql/statsdb.py
==============================================================================
--- gump/trunk/python/gump/stats/mysql/statsdb.py	(original)
+++ gump/trunk/python/gump/stats/mysql/statsdb.py	Wed Aug 11 11:16:45 2004
@@ -76,7 +76,7 @@
             
         # print 'ThreadSafe : ' + `MySQLdb.threadsafety`
         
-        self.helper=gump.utils.mysql.DbHelper(self.conn)
+        self.helper=gump.utils.mysql.DbHelper(self.conn,dbInfo.getDatabase())
  
     # Workspace
     def getWorkspaceStats(self,workspaceName):

Modified: gump/trunk/python/gump/utils/mysql.py
==============================================================================
--- gump/trunk/python/gump/utils/mysql.py	(original)
+++ gump/trunk/python/gump/utils/mysql.py	Wed Aug 11 11:16:45 2004
@@ -29,8 +29,9 @@
     	MySQL Statistics Database Interface
     """
 
-    def __init__(self,conn):
+    def __init__(self,conn,database='gump'):
         self.conn=conn
+        self.database=database
         
     def __del__(self):
         if self.conn:
@@ -41,7 +42,7 @@
         """
         Generate a select statement, index is a single name
         """ 
-        statement="SELECT * FROM gump.gump_%s WHERE %s='%s'" % (table_name, column_name,
entity_name) 
+        statement="SELECT * FROM %s.gump_%s WHERE %s='%s'" % (self.database, table_name,
column_name, entity_name) 
         return statement
         
     def select(self,table_name,column_name,entity_name,columns):
@@ -85,7 +86,7 @@
         """ 
         Perform an SQL INSERT 
         """
-        statement = "INSERT INTO gump.gump_%s (" % table_name
+        statement = "INSERT INTO %s.gump_%s (" % (self.database, table_name)
         keys=settings.keys()
         statement += ", ".join(keys)
         statement += ") VALUES ("
@@ -120,7 +121,7 @@
         Take a dictionary of settings (column names/types) and 
         generate an update statement. Note: The index is a single name.        
         """
-        statement = "UPDATE gump.gump_%s SET " % table_name
+        statement = "UPDATE %s.gump_%s SET " % (self.database, table_name)
         keys=settings.keys()
         keys.remove(column_name)
         statement += ", ".join([key + '=' + str(settings[key]) for key in keys])
@@ -154,8 +155,8 @@
         Perform an SQL DELETE 
         Index is single name
         """
-        statement = "DELETE FROM gump.gump_%s WHERE %s='%s'" \
-                        % (table_name, column_name, entity_name)
+        statement = "DELETE FROM %s.gump_%s WHERE %s='%s'" \
+                        % (self.database, table_name, column_name, entity_name)
         return statement
 
     def delete(self,table_name,column_name,entity_name):       

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@gump.apache.org
For additional commands, e-mail: general-help@gump.apache.org


Mime
View raw message