设置pyodbc搜索odbcinst.ini文件的位置 [英] setting the location where pyodbc searches for odbcinst.ini file
问题描述
我正在尝试在 ubuntu 中使用 pyodbc 查询符合 ODBC 的数据库.为此,我已经安装了驱动程序(比如 mysql-odbc-driver).安装后,在 /usr/share/libmyodbc/odbcinst.ini 位置创建带有配置的 odbcinst.ini 文件当我尝试使用我的 pyodbc 连接代码连接到数据库时,我收到 driver not found 错误消息.现在,当我将文件内容复制到 /etc/odbcinst.ini 时,它起作用了!
I am trying to query ODBC compliant databases using pyodbc in ubuntu. For that, i have installed the driver (say mysql-odbc-driver). After installation the odbcinst.ini file with the configurations gets created in the location /usr/share/libmyodbc/odbcinst.ini When i try to connect to the database using my pyodbc connection code, i get a driver not found error message. Now when I copy the contents of the file to /etc/odbcinst.ini, it works!
这意味着 pyodbc 在文件 /etc/odbcinst.ini 中搜索驱动程序信息.
This means pyodbc searches for the driver information in file /etc/odbcinst.ini.
如何更改在odbcinst.ini文件中搜索驱动信息的位置
How can I change the location where it searches the odbcinst.ini file for the driver information
谢谢.
推荐答案
假设您使用的是 unixODBC,这里有一些可能性:
Assuming you are using unixODBC here was some possibilities:
- 从头开始重新构建 unixODBC 并设置 --sysconfdir
- 导出指向目录的 ODBCSYSINI env var,unixODBC 将在此处查找 odbcinst.ini 和 odbc.ini 系统 dsns
- 导出 ODBCINSTINI 并将其指向您的 odbcinst.ini 文件
顺便说一句,我怀疑 pyodbc 会在 odbcinst.ini 文件中查找任何内容,但 unixODBC 会.有可用于检查 ODBC ini 文件的 ODBC 驱动程序管理器 API 列表.
BTW, I doubt pyodbc looks anything up in the odbcinst.ini file but unixODBC will. There is a list of ODBC Driver manager APIs which can be used to examine ODBC ini files.
这篇关于设置pyodbc搜索odbcinst.ini文件的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!