Connecting FileMaker Pro with MySQL in Mac OS X

Connecting FileMaker Pro with MySQL in Mac OS X

10.12.2007
Written by: J. Zatkulak
Connecting FileMaker Pro 9 with MySQL in Mac OS X

By Danny Kohn

Previous Versions of FileMaker Pro and ODBC

Filemaker Pro has had the ability to connect to and use ODBC as early as version 7. Using the Execute SQL script step, you could specify a ODBC DSN (Database Source Name) and execute any SQL statement that you can build with a FileMaker Pro calculation which could include field data.

Limitations of this functionality included the following:

  • Communication is only one way.
  • You must be well versed in SQL.
  • It must be done through a script.

In databases I had created in FileMaker Pro 7 where data synchronization with a MySQL database was required, I was forced to first delete all data in each MySQL table before repopulating it with live data from the FileMaker database.

FileMaker Pro 9 and ODBC

In FileMaker Pro 9, ODBC connections are treated like a FileMaker Pro external data source, formerly known as file references. The data source acts similar to a reference to another FileMaker Pro database file. Tables can be added to the relationship graph, layouts can be created showing records from a MySQL (or any ODBC capable database) table. Calculations can be made in the context of a data source table. You can even add calculation and summary fields to the tables for use within FileMaker Pro.

Through a layout, you can then add, remove or modify the external records as if they were in a FileMaker Pro table. No SQL required. No scripts required. Theoretically, you could create an entire FileMaker Pro database based solely on MySQL data tables with no tables defined within the FileMaker Pro file.

You can now use FileMaker Pro as a friendly front-end to any MySQL, MS SQL, Oracle, Access or any ODBC capable database. The only thing you can not do from within FileMaker Pro is create tables and fields.

What is ODBC?

ODBC, an acronym for Open Database Connectivity, is a standard protocol for communicating with databases. It allows users to set up a DSN, or Database Source Name, that can be used by any ODBC aware application on a particular computer to send queries and receive data from a specified data source. It is kind of like having a shortcut or alias on your desktop linking to a file on a server, except the shortcut is a DSN and instead of a file on a server, it links to a database.

By setting up a DSN, you are assigning an arbitrary name, or shortcut, that will be recognized by your computer as a pointer to a server and database. The scope of a DSN can be restricted to a particular computer user or to a computer system. A single DSN can not be used on multiple computers. If database connectivity is required on multiple computers, it is necessary to set up a DSN on each computer.

ODBC Setup Overview for FileMaker Pro 9

There are 4 basic steps for getting FileMaker Pro 9 to work with other databases.

  1. Install an ODBC Driver.
  2. Set up the DSN.
  3. Add the DSN data source to the FileMaker Pro database.
  4. Add the table(s) to the relationship graph.

Each of these steps is explained in detail below.

Installing the MySQL ODBC Driver for Mac OS X

There are a number of MySQL ODBC drivers available for Mac OS X, many of which have simple package installers. I have only managed to get one to work properly with FileMaker Pro: Actual ODBC Driver for Open Source Databases. It comes with a $30 price tag.

MySQL.com has a free, open-source driver available, but I could not get it to work properly for FileMaker due, apparently due to a bug in Mac OS X's iODBC driver manager. If you are interested in the details, I filed a bug report. Hopefully, they will have a work around soon.

Both drivers come with an easy to use, standard OS X package installer. Download, double click, click Next a few times, and you are done.

Setting Up the DSN

Once the driver is installed, you can create a DSN using the Mac OS X ODBC Administrator program located at Applications/Utilities/ODBC Administrator. FileMaker Pro 9 only supports system data sources and does not support user data sources. So, you must add a User DSN:

  • Select the User DSN tab.
  • Click the lock and authenticate to allow changes.
  • Click Add.
  • Choose the appropriate driver (probably "Actual Open Source Databases").
  • Click Continue.
  • Enter a name for the data source. This can be whatever makes sense to you, but if two or more computers are being set up to use the same source, the names must be identical.
  • Click Continue and enter the MySQL database server address.
  • Enter MySQL database server login information and click continue.
  • Click the drop down arrow next to the Database field and select the database to which this DSN should link. If a list of databases on the MySQL server appears in this drop down, you know a successful connection was made.
  • Click Finish or Continue if you wish to review the settings and test the connection.
Using the Data Source in FileMaker

In the FileMaker Pro database, perform the following steps:

  • Open the Manage External Data Sources window through the File->Manage->External Data Sources... menu item.
  • Click New..., to add a data source.
  • Enter a name, choose ODBC, then click the Specify... button.
  • Choose the DSN data source you recently created and click OK.
  • If you wish, enter a user name and password for the MySQL server, or you may leave it set to require entry by users. Since you can use calculations to specify user credentials, you can easily customize the authentication process, including passing the user's FileMaker Pro database user name and password to the MySQL server. Keeping users synchronized between databases is a topic worthy of its own article.
Add a Table to the Relationship Graph

The rest of the process is quite simple. When you go to the relationship graph and click the Add Table button, you will see your new data source in the Data Sources drop down menu. Select it and add the desired table as you would with any FileMaker Database. You can then include it in any relationships, create new layouts with it and add Calculation and Summary fields under the Fields tab.

Danny Kohn is a Software Engineer and Consultant for Inspirations Software Design (ISD). ISD is an IT services and consulting firm specializing in custom business solutions with human interfaces that are easy to learn and simple to use.

For answers to your FileMaker Pro, MySQL or ODBC questions, help developing the database you need or integrating your FileMaker Pro database with your PHP web site or MySQL database, visit http://www.InspirationsSoftwareDesign.com

Article Source: http://EzineArticles.com/expert/Danny_Kohn/132312
http://EzineArticles.com/?Connecting-FileMaker-Pro-with-MySQL-in-Mac-OS-X&id=780323