'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('\n                                                SELECT    attr.attname,    idx.indkey,    idx.indisunique,    idx.indisprimary\n                                                FROM    pg_catalog.pg_class    c,    pg_catalog.pg_class    c2,\n                                                                pg_catalog.pg_index    idx,    pg_catalog.pg_attribute    attr\n                                                WHERE    c.oid    =    idx.indrelid\n                                                                AND    idx.indexrelid    =    c2.oid\n                                                                AND    attr.attrelid    =    c.oid\n                                                                AND    attr.attnum    =    idx.indkey[0]\n                                                                AND    c.relname    =    %s', [table_name])
    indexes = {}
    for row in cursor.fetchall():
        if ('    ' in row[1]):
            continue
        indexes[row[0]] = {'primary_key': row[3], 'unique': row[2]}
    return indexes
