Perform a query to get the data from a specified unit either as an applescript list of lists or alternatively writing the data to a file.