10.41.1 Problem
You want to exchange information between MySQL and FileMaker Pro.
10.41.2 Solution
Under Windows, you can make an ODBC connection from FileMaker Pro to the MySQL server. Alternatively, you can export tables into files from MySQL and import them into FileMaker Pro, or vice versa. But watch out for conversion issues like incompatible date column types.
10.41.3 Discussion
If you can connect from FileMaker Pro to your MySQL server over an ODBC connection, you can access MySQL tables that way. The procedure is similar to that for connecting to MySQL from Access. (See Recipe 10.39.)
Another option is to export data from one program into files and then import them into the other program. The transfer directory of the recipes distribution contains a mysql_to_filemaker.pl utility that exports a MySQL table to a file that you can import into FileMaker Pro. This script is designed to handle the following FileMaker Pro-specific issues:
To process date values, mysql_to_filemaker.pl uses a technique similar to that shown earlier in Recipe 10.34 for constructing a SELECT statement that exports table data with the dates rewritten. That is, it reads the table metadata to detect date-based columns and exports them using calls to DATE_FORMAT( ) that rewrite the column values into FileMaker Pro format.
mysql_to_filemaker.pl writes output in what FileMaker Pro calls merge format, which is essentially CSV format with an initial row of column labels. Merge files are useful with FileMaker Pro for a couple of reasons:
mysql_to_filemaker.pl requires database name and table name arguments on the command line. For example, to export the contents of the mail table to a merge file mail.mer, you'd invoke the script like this:
% mysql_to_filemaker.pl cookbook mail > mail.mer
The mail table has a column t that contains DATETIME values. If you examine mail.mer, you'll see that mysql_to_filemaker.pl exports t as two separate columns, t_date and t_time, with the order of the date parts rearranged from ISO to MM-DD-CCYY format:
t_date,t_time,srcuser,srchost,dstuser,dsthost,size 05-11-2001,10:15:08,barb,saturn,tricia,mars,58274 05-12-2001,12:48:13,tricia,mars,gene,venus,194925 05-12-2001,15:02:49,phil,mars,phil,saturn,1048 05-13-2001,13:59:18,barb,saturn,tricia,venus,271 05-14-2001,09:31:37,gene,venus,barb,mars,2291 ...
mysql_to_filemaker.pl also understands the usual options for specifying connection parameters (such as --user or --host). Any options must precede the database name argument.
After you create the merge file, you can tell FileMaker Pro to open it directly (which will create a new table) or to import it into an existing database.
To go the other direction and import a FileMaker Pro database into MySQL, use the following procedure:
Using the mysql Client Program
Writing MySQL-Based Programs
Record Selection Techniques
Working with Strings
Working with Dates and Times
Sorting Query Results
Generating Summaries
Modifying Tables with ALTER TABLE
Obtaining and Using Metadata
Importing and Exporting Data
Generating and Using Sequences
Using Multiple Tables
Statistical Techniques
Handling Duplicates
Performing Transactions
Introduction to MySQL on the Web
Incorporating Query Resultsinto Web Pages
Processing Web Input with MySQL
Using MySQL-Based Web Session Management
Appendix A. Obtaining MySQL Software
Appendix B. JSP and Tomcat Primer
Appendix C. References