What's causing 'unable to connect to data source' for pyodbc?

前端 未结 13 2258
北荒
北荒 2020-12-28 14:34

I\'m trying to connect to an MSSQL database from python on Linux (SLES).

I have installed pyodbc and Free TDS. From the command line:

tsql -H server          


        
13条回答
  •  余生分开走
    2020-12-28 15:23

    This worked for me, not sure but thought that it might help someone

    run below command to find which version of odbcinst and isql you are using

     which odbcinst
    
     which isql
    

    Then run $ odbcinst -j to find which odbc.ini and odbcinst.ini is getting used.

    In odbcinst.ini add

    [FreeTDS]
    Description=FreeTDS Driver for Linux & MSSQL
    Driver=/usr/local/lib/libtdsodbc.so
    Setup=/usr/local/lib/libtdsodbc.so
    UsageCount=1
    

    And in odbc.ini configure your server as

    [YOUR_SERVER]
    Driver = FreeTDS
    Servername = 
    Database = 
    

    I found some good description at https://docs.snowflake.net/manuals/user-guide/odbc-linux.html#unixodbc

    Also take a look at https://github.com/lionheart/django-pyodbc/wiki/Mac-setup-to-connect-to-a-MS-SQL-Server

提交回复
热议问题