Combining Applescript, FileMaker and MySQL

I have years of SQL experience from a previous life and found it very hard to start using FileMaker for my database requirements when I moved to Mac. However, I’m now having great success storing my data in a MySQL database and using Applescript (executed from buttons created in Filemaker) to fire off SQL statements to manipulate and manage my data. I do this by executing shell script commands that execute the SQL. I even pass Applescript variables to my SQL commands which effectively gives me a complete procedural SQL environment using applescript (similar to Oracle’s PLSQL) I use Filemaker to view and report on my data - using the excellent ODBC link. It’s absolutely fantastic and works perfectly with no bugs or problems (so far). I just thought I’d mention it because I can’t seem to find any hint of anyone else doing the same thing - so anyone searching or thinking about doing similar might be encouraged.

I have some experience with filemaker and am able to tie AppleScripts to buttons as you have with great success. However a have no experience with MySQL or shell scripts but many reasons to learn as my works systems use mysql. Is there a good resourse you could recommend for beginners? Thanks.

Probably because only the newest versions of FileMaker (9 and 10) have decent ODBC links. They were either bad, or 3rd part AND bad before that. :stuck_out_tongue:

I don’t know SQL that well, though at some point I should get the interactive group to show me enough to access their data via FileMaker, which I know pretty well (Intermediate).

My basic do shell script looks like:

do shell script (“/usr/local/mysql/bin/mysql -u root </Users/lloyd/Desktop/main/Scripts/sql/mysql_load_table_expenditures.sql”)

Which is a simple unix command to start mysql and run an sql script on the same line. All my SQL statements are in the .sql file.

The following script is an example of passing an applescript variable to an sql statement:

set appVar to 12

do shell script (“/usr/local/mysql/bin/mysql -u root -e "set @myvar:='” & appVar & “'; source /Users/lloyd/Desktop/main/Scripts/sql/mysql_example_using_variables.sql;"”)

where in this case my mysql_example_using_variables.sql file contained the simple sql line:

select sum(Net_Value) from jobs where VAT_Period=@myvar;

After executing sql statement, I can pass variable values back to applescript by writing the values to a dedicated sql table field and reading the value using Filemaker applescript statements.

This is about all you need to know to link Applescript, Filemaker and MySQL into one hell of a powerful and flexible environment. The rest is either straight Applescript, SQL or Filemaker which you can learn from any or their respective resources - sorry about the cliche but limited only by imagination (or requirements!!)

Thanks for that. I think the learning curve isn’t too steep. Even for me!