#NEWLINE# def get_relations( self , cursor , table_name ) : #NEWLINE# #INDENT# '\n        Returns a dictionary of {field_index: (field_index_other_table, other_table)}\n        representing all relationships to the given table. Indexes are 0-based.\n        ' #NEWLINE# cursor . execute ( "\n            SELECT con.conkey, con.confkey, c2.relname\n            FROM pg_constraint con, pg_class c1, pg_class c2\n            WHERE c1.oid = con.conrelid\n                AND c2.oid = con.confrelid\n                AND c1.relname = %s\n                AND con.contype = 'f'" , [ table_name ] ) #NEWLINE# relations = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for row in cursor . fetchall ( ) : #NEWLINE# #INDENT# relations [ ( row [ 0 ] [ 0 ] - 1 ) ] = ( ( row [ 1 ] [ 0 ] - 1 ) , row [ 2 ] ) #NEWLINE# #UNINDENT# return relations