Python – Connecting to FileMaker via JDBC on Linux
Monday, May 9th, 2011Notes: This should work on FileMaker Pro 9 and 10. FileMaker Pro 11 might be different.
The trick here is you can’t use FileMaker’s ODBC library as that is only for Windows (and Mac?). You need to use the cross platform JDBC driver.
Firstly get the sljc.jar file out of the FileMaker installation media (Instructions here). I placed the sljc.jar file in /opt/drivers and I made sure /opt/drivers is owned by myself:
$ sudo chown pinerog:scicomp /opt/drivers
Now install the Python libraries you’ll need:
JPype – a library to allow Python to access Java libraries
To Install:
> cd /opt/source > wget http://downloads.sourceforge.net/project/jpype/JPype/0.5.4/JPype-0.5.4.1.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fjpype%2Ffiles%2F&ts=1304951217&use_mirror=iweb > unzip JPype-0.5.4.1.zip > cd JPype-0.5.4.1/ # I had to install open jdk dev > sudo yum install java-1.6.0-openjdk-devel.x86_64 #Open up setup.py and find the function 'setupLinux' and set self.javaHome to "/usr/lib/jvm/java" or whatever your Java Home is > sudo python setup.py install # (Note: It still won't know where Java home is even after installed so before you use this lib, set your JAVA_HOME env variable: export JAVA_HOME=/usr/lib/jvm/java or where ever yours is)
(I got some help figuring out the Java issues here.)
JayDeBeApi – a library to let you connect Python to JDBC connections
To Install:
$ sudo easy_install JayDeBeApi
(I got help using JayDeBeApi here.)
Sample Code:
Finally you’re ready to use this stuff.
# You'll probably need to set your Java Home env var before running:
# $ export JAVA_HOME=/usr/lib/jvm/java (or where ever yours is)
import jaydebeapi
import jpype
URL = 'jdbc:sequelink://10.21.41.26:2399;serverDataSource=FLA'
jar = r'/opt/drivers/sljc.jar' #path to driver
args='-Djava.class.path=%s' % jar
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(jvm_path, args)
conn = jaydebeapi.connect('com.ddtek.jdbc.sequelink.SequeLinkDriver',
URL, 'username', 'pw')
curs = conn.cursor()
curs.execute('''select * from LabHead''')
print curs.fetchall()[:100]
–
Update: There are a couple of changes for working with FileMaker 11.