Pyodbc - “Data source name not found, and no default driver specified”

后端 未结 5 1949
闹比i
闹比i 2020-11-27 15:39

I have trouble getting pyodbc work. I have unixodbc , unixodbc-dev, odbc-postgresql, pyodbc packages install

5条回答
  •  有刺的猬
    2020-11-27 16:14

    For me, the issue was the actual location of my odbc.ini and odbcinst.ini files.

    On many systems, the install location of these files is in /etc/

    However, in my case, these files were located under /usr/local/etc/

    The could be determined by typing
    odbcinst -j

    Which yielded:

    unixODBC 2.3.0
    DRIVERS............: /usr/local/etc/odbcinst.ini
    SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
    FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
    USER DATA SOURCES..: /usr/local/etc/odbc.ini
    SQLULEN Size.......: 8
    SQLLEN Size........: 8
    SQLSETPOSIROW Size.: 8
    

    My odbc.ini files already exists in /etc, so the solution was to copy them over over from /etc/ to /usr/local/etc/

    cp /etc/odbc.ini /etc/odbcinst.ini /usr/local/etc/

    Edit: It's also worth noting that the path outputted by the odbcinst -j command can change depending on using sudo or not.

提交回复
热议问题