Here you are my contribution (of an AS absolute beginner) to the discussion ignited by myself. I'm profitably using a PostgreSQL DB to consult thousands of meteorological data. psql is the shell commmand to deal with this db. I noticed that is much better to simplify the otherwise neat and nice-looking output adding the following option to the command line: -A = doesn't align the output -t = I want tuples only without headers -R = character(s) for the end of each record (I chose the unfrequent '§') -F = character(s) field separator (in my case "," according to the standard CSV style) -c = command to be executed as a string
the subroutine returns a list
For me it works and I think that with small adjustement the same routine can be used for MySQL.
Ciao Vittorio
property psqlCommand : "/sw/bin/psql"
on SQLExecute(DatabaseName, sqlCommand) set resultText to (do shell script psqlCommand & space & DatabaseName & space & ¬ "-A -t -R '§' -F ',' -c " & (quoted form of sqlCommand)) if length of resultText = 0 then return resultText end if set text item delimiters to "§" set these_items to the text items of resultText set text item delimiters to "," repeat with i from 1 to count of items of these_items set item i of these_items to text items of item i of these_items end repeat return these_items
end SQLExecute
on run set DBName to "meteodm" set resultList to SQLExecute(DBName, " select * from regioni where id > 115 order by id;") .................................. |