Pyodbc驱动程序:如何在macOS中指定其位置? [英] Driver for pyodbc: how to specify its location in macOS?

查看:128
本文介绍了Pyodbc驱动程序:如何在macOS中指定其位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于以下带有Pyodbc软件包的Python 3命令,我想找到一种方法来指定驱动程序的路径-或解决Pyodbc无法找到Vertica驱动程序的问题

Pyodbc.connect(...)

但是我不断收到错误消息,找不到Vertica驱动程序9.0.x.我在此处和安装程序 pyODBC:在Windows中指定驱动程序的位置

解决方案

  1. 确认 iODBC是最新的. (Apple在macOS中提供了过时的iODBC版本.)
  2. 使用指向iODBC的链接构建pyodbc(这不是默认的UnixODBC,这对于macOS而言并不常见).
  3. 使用iODBC Administrator.app(/Applications/iODBC/)配置ODBC数据源名称(DSN),它将被保存到默认文件中:
    • 系统DSN:/Library/ODBC/odbc.ini
    • 用户DSN:~/Library/ODBC/odbc.ini
  4. 如果pyodbc或其他工具需要$ODBCINI环境变量或类似设置,请将它们指向上述文件.
  5. 享受.

I want to find a way to specify the path of a driver -- or otherwise resolve problem that Pyodbc cannot find a Vertica driver -- for the following Python 3 command with Pyodbc package

Pyodbc.connect(...)

but I keep getting the error that a Vertica driver 9.0.x cannot be found. I used the installer here and the installer here on macOS.

I currently use an alias Vertica in the command but unknown for the Pyodbc connect so apparently some driver file problem, now need to find a way to resolve this.

How can I specify the location of the driver for pyodbc? Or otherwise resolve why the driver unknown?

Updated comments on TaliTedi answer.

  1. How to confirm that iODBC is up-to-date?

  2. How to build pyodbc with links to iODBC?

  3. The directory ~/Library/ODBC/odbcini does not exist. How to configure the DNSs?

Older pyodbc threads

  1. pyODBC: specify location of driver in Windows

解决方案

  1. Confirm that iODBC is fully up-to-date. (Apple ships an outdated version of iODBC in macOS.)
  2. Build pyodbc with links to iODBC (not its default of UnixODBC, which is not typical for macOS).
  3. Use iODBC Administrator.app (/Applications/iODBC/) to configure ODBC Data Source Names (DSNs), which will be saved to default files:
    • System DSNs: /Library/ODBC/odbc.ini
    • User DSNs: ~/Library/ODBC/odbc.ini
  4. If pyodbc or other tools require $ODBCINI environment variable or similar settings, point them to the file(s) noted above.
  5. Enjoy.

这篇关于Pyodbc驱动程序:如何在macOS中指定其位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆