Search code examples
odbcunixodbc

unixODBC + ODBC Driver 13


I want to connect to MSSQL database with following odbc.ini:

[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.0
Trace=yes
TraceFile=/db.log
User=[user]
Password=[password]
Server=[server]\[instance]
Database=[db_name]
UsageCount=5

I am able to connect to DB from PyCharm, so credentials should be fine. Everything is installed in vagrant with Debian 8 and unixODBC version is 2.3.1. Error message is following:

[HYT00][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired
[08001][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF].
[08001][unixODBC][Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
[ISQL]ERROR: Could not SQLConnect

I don't have db.log file and i don't know how to figured out where is problem. When i trying to ping server from vagrant everything works fine.

I also try sqlcmd tool on windows and also on ubuntu 16.04 outside of vagrant. On windows everything works fine but on Ubuntu same error occures. Command:

sqlcmd -S [server]\[instance] -U [user] -d [table_name] -P [password]

Do you have some advice how to trace or debug this problem ?


Solution

  • I found answer on DBA. So on Linux dont work command:

    sqlcmd -S [server]\[instance] -U [user] -d [table_name] -P [password]
    

    just

    sqlcmd -S [server],[port] -U [user] -d [table_name] -P [password]
    

    And you need to find out this port somehow. After this also Pyodbc start to work