最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - pyodbc not reading specified FILEDSN - Stack Overflow

programmeradmin4浏览0评论

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.

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.

Share Improve this question edited Jan 21 at 14:11 Equino asked Jan 21 at 11:18 EquinoEquino 816 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

According to the docs:

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

Note that unixODBC is a driver manager, not a driver.

You might consider switching to the iODBC driver manager, which is maintained by OpenLink Software, also the source of Virtuoso.

发布评论

评论列表(0)

  1. 暂无评论