'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):

    indexes = {}
    for info in self._table_info(cursor, table_name):
        indexes[info['name']] = {'primary_key': (info['pk'] != 0), 'unique': False}
    cursor.execute(('PRAGMA    index_list(%s)' % self.connection.ops.quote_name(table_name)))
    for (index, unique) in [(field[1], field[2]) for field in cursor.fetchall()]:
        if (not unique):
            continue
        cursor.execute(('PRAGMA    index_info(%s)' % self.connection.ops.quote_name(index)))
        info = cursor.fetchall()
        if (len(info) != 1):
            continue
        name = info[0][2]
        indexes[name]['unique'] = True
    return indexes
