'Returns a dictionary of fieldname -> infodict for the given table,
where each infodict is in the format:
{\'primary_key\': boolean representing whether it\'s the primary key,
\'unique\': boolean representing whether it\'s a unique index}'

def get_indexes(self, cursor, table_name):

    cursor.execute(('SHOW    INDEX    FROM    %s' % self.connection.ops.quote_name(table_name)))
    indexes = {}
    for row in cursor.fetchall():
        indexes[row[4]] = {'primary_key': (row[2] == 'PRIMARY'), 'unique': (not bool(row[1]))}
    return indexes
