IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 25, 2011, 3:21:40 PM (15 years ago)
Author:
rhenders
Message:

new method to find and delete rows that have a field with the provided value

File:
1 edited

Legend:

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

    r31366 r31380  
    106106
    107107    '''
     108    Reports the number of rows with this columns set as this numeric value and then deletes them
     109    '''
     110    def reportAndDeleteRowsWithThisValue(self, tableName, columnName, value):
     111
     112        sql = "SELECT COUNT(*) FROM " + tableName + " WHERE " + columnName + " = " + value
     113        rs = self.stmt.executeQuery(sql)
     114        rs.first()
     115        nBadFlux = rs.getInt(1)
     116        self.logger.info("%d NULL %s values in table %s. Deleting." % (nBadFlux, columnName, tableName))
     117
     118        sql="DELETE from " + tableName + " WHERE " + columnName + " = " + value
     119        self.stmt.execute(sql)
     120
     121    '''
    108122    Reports the number of rows with this column NULL and then deletes them
    109123    '''
Note: See TracChangeset for help on using the changeset viewer.