I am trying to connect to MS-SQL server via ODBC, probably this is one of most asked questions but this one is very strange because same configuration works in my local machine, I mean I did everything on my local computer and its OK, but now in other machine not working.
I've installed prerequisite packages via
sudo apt-get install unixodbc unixodbc-dev freetds-dev freetds-bin tdsodbc
My configurations
/etc/freetds/freetds.conf
# A typical Microsoft server
[SQLDemo]
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 8.0 # I've tried 7.0, 7.2 as well
-----------------------------------------------
/etc/odbc.ini
[SQLDemo]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Server=xxx.xxx.xxx.xxx\SQL2014 #I've tried servername=SQLDemo as well
Database = MY_DB_NAME
-----------------------------------------------
/etc/odbcinst.ini
[ODBC]
Trace=Yes
TraceFile=/home/odbc_trace.log
[FreeTDS]
Description = TDS Driver (Sysbase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
FileUsage = 1
I'm running below piece of code and get the error
cnnstr = 'DSN=%s;UID=%s;PWD=%s' % ('SQLDemo', 'xyz', 'xyz');
db = pyodbc.connect(cnnstr);
pyodbc.Error: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
I need to know whats wrong here. I need to mention again same config/code works in my local computer.
both machines are Ubuntu 16.04
Thanks in advance