-
Notifications
You must be signed in to change notification settings - Fork 568
Description
The pyodbc.Error
I don't seem to be able to connect to a local FileMaker Pro database running on the same computer. I'm using pyodbc with unixODBC on MacOS:
>>> import pyodbc
>>> dsn = "Driver=/Library/ODBC/FileMaker ODBC.bundle/Contents/MacOS/fmodbc.so;\
Server=localhost;Port=2399;Database=MyDatabase;UID=Admin;PWD="
>>> pyodbc.connect(dsn)
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
pyodbc.connect(dsn)
~~~~~~~~~~~~~~^^^^^
pyodbc.Error: ('0000', '[0000] [ (1) (SQLDriverConnect)')
unixODBC does work (and so did pyodbc)...
There should be a way to get this to work: the unixODBC-provided isql tool seems to work just fine (-k ensures it is using SQLDriverConnect instead of SQLConnect):
isql -k -v "Driver=/Library/ODBC/FileMaker ODBC.bundle/Contents/MacOS/fmodbc.so;Server=localhost;Port=2399;Database=MyDatabase;UID=Admin;PWD="
SQL> help
This does list the tables in my database. So at least I know the connection through unixODBC works as intended.
Even more annoyingly, the combination of pyodbc with unixODBC worked for me in the past (at least 2018-2022, perhaps later), as long as I set the encoding after establishing a connection:
connection = pyodbc.connect(dsn)
connection.setencoding(encoding='utf-8')
connection.setdecoding(pyodbc.SQL_CHAR, encoding='macroman')
However, today (end 2025), it already fails during the pyodbc.connect() call.
I strongly suspect this to be a encoding issue (perhaps sprinkled with some bugs in the FileMaker ODBC implementation), but can't seem to get to find a working solution with pyodbc.
My Questions
Before I list more technical details, my main questions:
- Is there a known solution or work-around?
- Would it be possible to add an entry for FileMaker Pro on https://github.com/mkleehammer/pyodbc/wiki ? (even if it is just an entry stating that FileMaker is too buggy, and is not supported)
Technical details of my setup
- Running MacOS 15.7.3 (Sequia) on Apple silicon (M2 Pro processor)
- FileMaker Pro 20 (2023)
- Installed FileMaker ODBC Client Driver, as downloaded from the Claris (FileMaker) support website: https://support.claris.com/s/answerview?language=en_US&anum=12921
- Installed the ODBC Manager by Actual Technologies, found on www.odbcmanager.net (and linked from the above support website).
- Installed unixODBC using MacPorts:
port install unixODBC - Installed pyodbc using pip:
pip install pyodbc --no-binary :all:(build from source, because the binary distribution hardcoded a link to unixODBC which is Homebrew-specific)
The version that worked for me in the past also used the same install process, only earlier versions of MacOS, and perhaps also an older version of FileMaker Pro.
Attempts to debug the situation
I did try with FileMaker Pro 22 (2025) as well, but that seems to have the same problem. I have not extensively tested that.
I did try to set the encoding with the pyodbc.connect() call, and got some different results:
| Command (with unixODBC) | Result |
|---|---|
pyodbc.connect(dsn) |
pyodbc.Error: ('0000', '[0000] [ (1) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-16LE') |
pyodbc.Error: ('0000', '[0000] [ (1) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-16BE')) |
pyodbc.InterfaceError: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found and no default driver specified (0) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-8')) |
pyodbc.InterfaceError: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found and no default driver specified (0) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-32')) |
pyodbc.InterfaceError: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found and no default driver specified (0) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-32LE') |
pyodbc.InterfaceError: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found and no default driver specified (0) (SQLDriverConnect)') |
| pyodbc.connect(dsn, encoding='non_existant'))` | SystemError: <built-in function connect> returned NULL without setting an exception |
I did not get a good trace log. I suspect that I configured the wrong file (ODBC Manager told me to use ~/Library/ODBC/odbcinst.ini; odbcinst -j told me to use /opt/local/etc/odbcinst.ini)
I tried to use iODBC instead of unixODBC, as explained on https://www.actualtech.com/python-osx-odbc.php
| Command (with iODBC) | Result |
|---|---|
pyodbc.connect(dsn) |
pyodbc.Error: ('IM0', '[IM0] [\x00i\x00O\x00D\x00B\x00C\x00]\x00[\x00D\x00r\x00i\x00v\x00e\x00r\x00 \x00M\x00a\x00n\x00a\x00g\x00e\x00r\x00]\x00N\x00o\x00 \x00d\x00a\x00t\x00a\x00 \x00s\x00o\x00u\x00r\x00c\x00e\x00 \x00 (0) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-16LE') |
pyodbc.Error: ('IM0', '[IM0] [\x00i\x00O\x00D\x00B\x00C\x00]\x00[\x00D\x00r\x00i\x00v\x00e\x00r\x00 \x00M\x00a\x00n\x00a\x00g\x00e\x00r\x00]\x00N\x00o\x00 \x00d\x00a\x00t\x00a\x00 \x00s\x00o\x00u\x00r\x00c\x00e\x00 \x00 (0) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-16BE') |
pyodbc.Error: ('IM0', '[IM0] [\x00i\x00O\x00D\x00B\x00C\x00]\x00[\x00D\x00r\x00i\x00v\x00e\x00r\x00 \x00M\x00a\x00n\x00a\x00g\x00e\x00r\x00]\x00N\x00o\x00 \x00d\x00a\x00t\x00a\x00 \x00s\x00o\x00u\x00r\x00c\x00e\x00 \x00 (0) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-8') |
pyodbc.Error: ('IM0', '[IM0] [\x00i\x00O\x00D\x00B\x00C\x00]\x00[\x00D\x00r\x00i\x00v\x00e\x00r\x00 \x00M\x00a\x00n\x00a\x00g\x00e\x00r\x00]\x00N\x00o\x00 \x00d\x00a\x00t\x00a\x00 \x00s\x00o\x00u\x00r\x00c\x00e\x00 \x00 (0) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-32') |
pyodbc.Error: ('IM0', '[IM0] [\x00i\x00O\x00D\x00B\x00C\x00]\x00[\x00D\x00r\x00i\x00v\x00e\x00r\x00 \x00M\x00a\x00n\x00a\x00g\x00e\x00r\x00]\x00N\x00o\x00 \x00d\x00a\x00t\x00a\x00 \x00s\x00o\x00u\x00r\x00c\x00e\x00 \x00 (0) (SQLDriverConnect)') |
pyodbc.connect(dsn, encoding='UTF-32LE') |
No error, valid connection |
| pyodbc.connect(dsn, encoding='non_existant')` | SystemError: <built-in function connect> returned NULL without setting an exception |
Clearly, it wants to tell me [IM0] [iODBC][Driver Manager]No data source (0) (SQLDriverConnect), but adds a few NULL characters. This also indicates some encoding issue to me.
Edit: Apparently pyodbc with iODBC does work, when I set the encoding to UTF-32LE.