def get_relations(cursor, table_name):
 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])
 relations = {}
 for row in cursor.fetchall():
  try:
   relations[(int(row[0][1:(-1)]) - 1)] = ((int(row[1][1:(-1)]) - 1), row[2])
  except ValueError:
   continue
 return relations

def get_relations ( cursor , table_name ) : 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 ] ) relations = { } for row in cursor . fetchall ( ) : try : relations [ ( int ( row [ 0 ] [ 1 : ( - 1 ) ] ) - 1 ) ] = ( ( int ( row [ 1 ] [ 1 : ( - 1 ) ] ) - 1 ) , row [ 2 ] ) except ValueError : continue return relations
returns a list of relation names of model .