Changeset 37246 for trunk/ippToPsps/jython/mysql.py
- Timestamp:
- Aug 12, 2014, 4:10:18 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/mysql.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/mysql.py
r35417 r37246 83 83 ''' 84 84 def lockTable(self, table): 85 # print "Locking table: " + table 85 86 self.execute("LOCK TABLES " + table + " WRITE") 86 87 … … 89 90 ''' 90 91 def unlockTables(self): 92 # print "Unlocking tables" 91 93 self.execute("UNLOCK TABLES") 92 94 … … 109 111 print "failed to kill connection: ", connectionID 110 112 113 def listTables(self): 114 115 sql = "show tables" 116 rs = self.executeQuery(sql) 117 while (rs.next()): 118 tableName = rs.getString(1) 119 # print "table: " + tableName 120 rs.close() 121 111 122 ''' 112 123 Checks whether this table exists … … 200 211 201 212 ''' 213 Add a column to the table 214 ''' 215 def addColumn(self, table, column, type): 216 217 sql = "ALTER TABLE " + table + " ADD COLUMN " + column + " " + type 218 try: self.execute(sql) 219 except: return 220 221 ''' 202 222 Drops a list of tables 203 223 ''' … … 271 291 except: pass 272 292 #self.logger.warn("Index already in place on '" + column + "' for table '" + table + "'") 293 294 def addPrimaryKeyWithIgnore(self, table, column): 295 # note that in mysql versions later than 5.1, this fails 296 # unless the following is called first: 297 # "set session old_alter_table=1" 298 299 # follow the command with 300 # "set session old_alter_table=0" 301 302 # OF COURSE, this fails for mysql version <= 5.1... 303 if self.scratchDb.version > 5.1: 304 self.scratchDb.execute("set session old_alter_table=1") 305 306 # I should probably do this before the whole table is built, right? 307 sql = "ALTER IGNORE TABLE " + table + " ADD PRIMARY KEY (" + column + ")" 308 self.scratchDb.execute(sql) 309 310 if self.scratchDb.version > 5.1: 311 self.scratchDb.execute("set session old_alter_table=0") 273 312 274 313 '''
Note:
See TracChangeset
for help on using the changeset viewer.
