python 在脚本中从 FileMaker Pro 数据库中提取数据的最佳方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best way to extract data from a FileMaker Pro database in a script?
提问by postfuturist
My job would be easier, or at least less tedious if I could come up with an automated way (preferably in a Python script) to extract useful information from a FileMaker Pro database. I am working on Linux machine and the FileMaker database is on the same LAN running on an OS X machine. I can log into the webby interface from my machine.
如果我能想出一种自动化的方式(最好是在 Python 脚本中)从 FileMaker Pro 数据库中提取有用的信息,我的工作会更容易,或者至少不会那么乏味。我在 Linux 机器上工作,FileMaker 数据库位于运行在 OS X 机器上的同一个 LAN 上。我可以从我的机器登录到 webby 界面。
I'm quite handy with SQL, and if somebody could point me to some FileMaker plug-in that could give me SQL access to the data within FileMaker, I would be pleased as punch. Everything I've found only goes the other way: Having FileMaker get data from SQL sources. Not useful.
我对 SQL 非常熟练,如果有人可以向我指出一些 FileMaker 插件,它可以让我通过 SQL 访问 FileMaker 中的数据,我会很高兴。我发现的一切都只是相反:让 FileMaker 从 SQL 源获取数据。没用处。
It's not my first choice, but I'd use Perl instead of Python if there was a Perl-y solution at hand.
这不是我的第一选择,但如果手头有 Perl-y 解决方案,我会使用 Perl 而不是 Python。
Note: XML/XSLT services (as suggested by some folks) are only available on FM Server, not FM Pro. Otherwise, that would probably be the best solution. ODBC is turning out to be extremely difficult to even get working. There is absolutely zero feedback from FM when you set it up so you have to dig through /var/log/system.log and parse obscure error messages.
注意:XML/XSLT 服务(如某些人所建议的)仅在 FM Server 上可用,在 FM Pro 上不可用。否则,这可能是最好的解决方案。事实证明,ODBC 甚至很难使用。当您设置 FM 时,FM 的反馈绝对为零,因此您必须挖掘 /var/log/system.log 并解析晦涩的错误消息。
Conclusion: I got it working by running a python script locally on the machine that queries the FM database through the ODBC connections. The script is actually a TCPServer that accepts socket connections from other systems on the LAN, runs the queries, and returns the data through the socket connection. I had to do this to bypass the fact that FM Pro only accepts ODBC connections locally (FM server is required for external connections).
结论:我通过在通过 ODBC 连接查询 FM 数据库的机器上本地运行 python 脚本使其工作。该脚本实际上是一个 TCPServer,它接受来自局域网上其他系统的套接字连接,运行查询,并通过套接字连接返回数据。我必须这样做以绕过 FM Pro 仅在本地接受 ODBC 连接的事实(外部连接需要 FM 服务器)。
采纳答案by Ryan Farley
It has been a reallylong time since I did anything with FileMaker Pro, but I know that it does have capabilities for an ODBC (and JDBC) connection to be made to it (however, I don't know how, or if, that translates to the linux/perl/python world though).
我已经很长时间没有使用 FileMaker Pro 做任何事情了,但我知道它确实具有与它建立 ODBC(和 JDBC)连接的功能(但是,我不知道如何,或者是否,虽然转换为 linux/perl/python 世界)。
This article shows how to share/expose your FileMaker data via ODBC & JDBC:
Sharing FileMaker Pro data via ODBC or JDBC
本文展示了如何通过 ODBC 和 JDBC 共享/公开您的 FileMaker 数据:通过 ODBC 或 JDBC
共享 FileMaker Pro 数据
From there, if you're able to create an ODBC/JDBC connection you could query out data as needed.
从那里,如果您能够创建 ODBC/JDBC 连接,您可以根据需要查询数据。
回答by cornwalker
You'll need the FileMaker Pro installation CD to get the drivers. This documentdetails the process for FMP 9 - it is similar for versions 7.x and 8.x as well. Versions 6.x and earlier are completely different and I wouldn't bother trying (xDBC support in those previous versions is "minimal" at best).
您需要 FileMaker Pro 安装 CD 来获取驱动程序。本文档详细介绍了 FMP 9 的过程 - 版本 7.x 和 8.x 也类似。6.x 版和更早的版本完全不同,我不会费心去尝试(这些以前版本中的 xDBC 支持充其量是“最低限度的”)。
FMP 9 supports SQL-92 standard syntax (mostly). Note that rather than querying tables directly you query using the "table occurrence" name which serves as a table alias of sorts. If the data tables are stored in multiple files it is possible to create a single FMP file with table occurrences/aliases pointing to those data tables. There's an "undocumented feature" where such a file must have a table defined in it as well and that table "related" to any other table on the relationships graph (doesn't matter which one) for ODBC access to work. Otherwise your queries will always return no results.
FMP 9 支持 SQL-92 标准语法(大部分)。请注意,不是直接查询表,而是使用用作各种表别名的“表出现”名称进行查询。如果数据表存储在多个文件中,则可以使用指向这些数据表的表出现/别名创建单个 FMP 文件。有一个“未记录的功能”,其中这样的文件还必须在其中定义一个表,并且该表与关系图上的任何其他表(与哪个表无关)“相关”,以便 ODBC 访问工作。否则您的查询将始终不返回任何结果。
The PDF document details all of the limitations of using the xDBC interface FMP provides. Performance of simple queries is reasonably fast, ymmv. I have found the performance of queries specifying the "LIKE" operator to be less than stellar.
PDF 文档详细说明了使用 FMP 提供的 xDBC 接口的所有限制。简单查询的性能相当快,ymmv。我发现指定“LIKE”运算符的查询的性能不如恒星。
FMP also has an XML/XSLT interface that you can use to query FMP data over an HTTP connection. It also provides a PHP class for accessing and using FMP data in web applications.
FMP 也有一个 XML/XSLT 接口,您可以使用它通过 HTTP 连接查询 FMP 数据。它还提供了一个 PHP 类,用于在 Web 应用程序中访问和使用 FMP 数据。
回答by cornwalker
If your leaning is to Python, you may be interested in checking out the Python Wrapper for Filemaker. It provides two way access to the Filemaker data via Filemaker's built-in XML services. You can find some quite thorough information on this at:
如果您倾向于 Python,您可能有兴趣查看 Filemaker 的 Python Wrapper。它通过 Filemaker 的内置 XML 服务提供对 Filemaker 数据的两种访问方式。您可以在以下位置找到一些非常详尽的信息: