IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33357 for trunk


Ignore:
Timestamp:
Feb 23, 2012, 4:19:12 PM (14 years ago)
Author:
rhenders
Message:

class variable to show if we are connected or not; method to check for other connections to this Db (used to determine if it is safe to use a particular scratch Db)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/mysql.py

    r33259 r33357  
    2121
    2222    '''
    23     def __init__(self, logger, config, dbType):
     23    def __init__(self, logger, config, dbType, dbName=None):
    2424
    2525        # set up logging
     
    2929
    3030        # open config and grab database parameters
    31         self.dbName = config.getDbName(dbType)
     31        if not dbName: self.dbName = config.getDbName(dbType)
     32        else: self.dbName = dbName
    3233        self.dbHost = config.getDbHost(dbType)
    3334        self.dbUser = config.getDbUser(dbType)
     
    4243        except:
    4344            self.logger.error("Unable to connect to " + self.url)
    44             self.everythingOK = False
     45            self.everythingOK = False # TODO need this?
     46            self.connected = False
    4547            return
    4648
    4749        self.everythingOK = True
     50        self.connected = True
    4851
    4952    '''
     
    5255    def disconnect(self):
    5356        self.con.close()
     57        self.connected = False
    5458
    5559    '''
     
    8589        sql = "KILL %d" % connectionID
    8690        self.execute(sql)
     91
     92    '''
     93    Checks whether there are any other connections to this database
     94    '''
     95    def anyOtherConnections(self):
     96
     97        sql = "SELECT COUNT(*) \
     98               FROM INFORMATION_SCHEMA.PROCESSLIST \
     99               WHERE DB='" + self.dbName + "'"
     100        try:
     101            rs = self.executeQuery(sql)
     102            rs.first()
     103            if rs.getInt(1) > 1: return True
     104            else: return False
     105        except:
     106            self.logger.errorPair("Could not check for connection", sql)
     107            pass
     108
     109        return True
    87110
    88111    '''
Note: See TracChangeset for help on using the changeset viewer.