Search code examples
pythonodbcpyodbcvirtuoso

pyodbc not reading specified FILEDSN


I am building an app that is supposed to establish an ODBC connection with a specific database server (An Openlink Virtuoso instance).
Until now I've been using a DSN specified in my odbc.ini file, and it worked properly. But now I am trying to make it so that the app embarks DSN information.

I have tried a simple FILEDSN in the connString but it looks like pyodbc doesn't use the specified file :

pyodbc.connect("FILEDSN=<path-to-file>.dsn;UID=<uid>;PWD=<pwd>")

yields the following error :

pyodbc.InterfaceError: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found and no default driver specified (0) (SQLDriverConnect)')

The .dsn file contains the exact same information that is in my odbc.ini file under that DSN :

[ODBC]
Driver              = /usr/lib/virtodbc_r.so
Address             = <my-endpoint>

The fact that it's unixODBC that's sending the error message makes me think pyodbc doesn't even read my .dsn file, since if it did it would use a different driver (the Virtuoso ODBC Driver). Is there something I'm missing here about pyodbc or connStrings ?

NB : I have managed to circumvent the issue through DSN-less connection for now, but getting the necessary information from ENV variables instead of a proper DSN definition looks like a bad practice.


Solution

  • According to the docs:

    "unixODBC does not at this time support FILEDSN's but it will when I get around to it."