setting the location where pyodbc searches for odbcinst.ini file

馋奶兔 提交于 2021-02-19 02:36:26

问题


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!

This means pyodbc searches for the driver information in file /etc/odbcinst.ini.

How can I change the location where it searches the odbcinst.ini file for the driver information

Thanks.


回答1:


Assuming you are using unixODBC here was some possibilities:

  • rebuild unixODBC from scratch and set --sysconfdir
  • export ODBCSYSINI env var pointing to a directory and unixODBC will look here for odbcinst.ini and odbc.ini system dsns
  • export ODBCINSTINI and point it at your odbcinst.ini file

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.



来源:https://stackoverflow.com/questions/11393269/setting-the-location-where-pyodbc-searches-for-odbcinst-ini-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!