IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31401


Ignore:
Timestamp:
Apr 28, 2011, 3:49:36 PM (15 years ago)
Author:
rhenders
Message:

added method to make a certain column of a certain table unique

File:
1 edited

Legend:

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

    r31387 r31401  
    6565        except: return
    6666
     67    '''
     68    Alters a column to be unique
     69    '''
     70    def makeColumnUnique(self, table, column):
     71
     72        self.logger.debug("Making '"+column+"' unique on table '"+table+"'")
     73
     74        sql = "ALTER TABLE " + table + " ADD UNIQUE (" + column + ")"
     75        try:
     76            self.stmt.execute(sql)
     77        except: pass
     78            #self.logger.warn("Index already in place on '" + column + "' for table '" + table + "'")
    6779    '''
    6880    Adds an index to the supplied table and column
     
    97109
    98110      sql = "UPDATE " + tableName + " SET " + column + " = " + sub + " WHERE " + column + " IS NULL"
    99       print sql
    100111      self.stmt.execute(sql)
    101112
Note: See TracChangeset for help on using the changeset viewer.