MySQL and Update Query


I’m using AppleScript and some shell scripts (using mysql) to do some maintenance on a database and I am writing some update queries. I also have CocoaMySQL which I use to admin the databases. In CocoaMySQL you can execute a custom query and see the results and it will also provide some data like Last Error Message: There were no errors, 4 row(s) affected. I know how to access results when I do a select query in AS but is it possible to see something similar to what Cocoa puts out for an update query?

So if in AS I had this:

property pathToMySQL : "/usr/local/mysql/bin/mysql"
property theHost : "10.1.1.xx"
property theUser : "xxxxxxxxx"
property thePassword : "xxxxxx"
property thePort : "3306"
property theLoginString : " -h " & theHost & " -u " & theUser & "  --password=" & thePassword

-->code to get variables<--

set query to "UPDATE scheduleTable SET beauty = " & beautystatus & ", product = " & productstatus & " WHERE folder LIKE '%" & itemfolder & "%'"
set theCommand to pathToMySQL & theLoginString & " storeSchedule -e \"" & query & "\""
set theUpdateResults to my doQuery(theCommand)

on doQuery(theCommand)
		set theResult to do shell script theCommand
		return theResult
	on error errMsg
		display dialog errMsg
	end try
end doQuery

how would I see the results? I’ve tried returning theUpdateResults and even counting the paragraphs of theUpdateResults but got nothing. Any help would be appreciated.

I think you are making this hard on yourself using AppleScript to work with
a MySQL db. You might try PHP since it has a rich set of methods to work
with MySQL. The command for affected rows is mysql_affected_rows();

You could also use Perl, Ruby or Python.

We all push AppleScript beyond what it was meant to do. :slight_smile: