Python - automating MySQL index: passing parameter
问题 I have a function with a new improved version of the code for automatic table indexing: def update_tableIndex(self,tableName): getIndexMySQLQuery = """SELECT numberID FROM %s;""" % (tableName,) updateIndexMySQLQuery = """UPDATE %s SET numberID=%s WHERE numberID=%s;""" % (tableName,) updateIndex=1 self.cursorMySQL.execute(getIndexMySQLQuery) for row in self.cursorMySQL: indexID = row[0] self.cursorMySQL.execute(updateIndexMySQLQuery,(updateIndex,indexID)) updateIndex+=1 While the query