This handler is intended to take the result of “do shell script mysql…” and parse it into a list of lists. This will enable you to create a data source in Applescript studio. I stripped the first line of the dataset as it was just field names. It is a little slow with long tables, so if anyone knows how to speed it up let me know.
OS version: OS X
on ParseMySQLDataset(dataset)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set resultList to {}
set resultSubList to {}
set resultSubStr to ""
repeat with i from 2 to count text items of dataset
set resultSubStr to text item i of dataset
set resultList to resultList & text item i of dataset
set AppleScript's text item delimiters to tab
set resultSubList to {}
repeat with x from 1 to count text items of resultSubStr
set resultSubList to resultSubList & text item x of resultSubStr
end repeat
set item (i - 1) of resultList to resultSubList
set AppleScript's text item delimiters to return
end repeat
set AppleScript's text item delimiters to oldDelim
return resultList
end ParseMySQLDataset