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

    sql = "SELECT    LOWER(all_tab_cols.column_name)    AS    column_name,\n                            CASE    user_constraints.constraint_type\n                                            WHEN    'P'    THEN    1    ELSE    0\n                            END    AS    is_primary_key,\n                            CASE    user_indexes.uniqueness\n                                            WHEN    'UNIQUE'    THEN    1    ELSE    0\n                            END    AS    is_unique\nFROM            all_tab_cols,    user_cons_columns,    user_constraints,    user_ind_columns,    user_indexes\nWHERE        all_tab_cols.column_name    =    user_cons_columns.column_name    (+)\n        AND        all_tab_cols.table_name    =    user_cons_columns.table_name    (+)\n        AND        user_cons_columns.constraint_name    =    user_constraints.constraint_name    (+)\n        AND        user_constraints.constraint_type    (+)    =    'P'\n        AND        user_ind_columns.column_name    (+)    =    all_tab_cols.column_name\n        AND        user_ind_columns.table_name    (+)    =    all_tab_cols.table_name\n        AND        user_indexes.uniqueness    (+)    =    'UNIQUE'\n        AND        user_indexes.index_name    (+)    =    user_ind_columns.index_name\n        AND        all_tab_cols.table_name    =    UPPER(%s)\n"
    cursor.execute(sql, [table_name])
    indexes = {}
    for row in cursor.fetchall():
        indexes[row[0]] = {'primary_key': row[1], 'unique': row[2]}
    return indexes
