I am facing issue while trying to access ms-sql database using pyobdc.
Here is the System config: Python 2.7.11 Pyodbc 3.0.7 RedHat 5.4 (Tikanga) 32 Bit system Microsoft SQL Server 2012 (Database server) unixODBC 2.3.0
$ tsql -C
output :
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
$ odbcinst -j
output :
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..: /root/.odbc.ini
SQLULEN Size.......: 4
SQLLEN Size........: 4
SQLSETPOSIROW Size.: 2
$ cat /usr/local/etc/odbcinst.ini
output :
[ms-sql]
Description=TDS connection
Driver=/usr/local/lib/libtdsodbc.so
Setup=/usr/local/lib/libtdsodbc.so
FileUsage=1
UsageCount=1
$ cat /usr/local/etc/odbc.ini
output :
[sqlserverdatasource]
Driver = ms-sql
Description = ODBC connection via ms-sql
Trace = No
Server = >IP Addresss To Database server<
Port = >Port Number<
Database = >Database name<
$ cat /etc/freetds.conf
output :
[sql-server]
host = >IP Addresss To Database server<
port = >Port Number<
tds version = 8.0
Command which is giving me error:
connection = pyodbc.connect(r'DRIVER={FreeTDS};SERVER=>IP Addresss To Database server<; PORT=>Port Number<;DATABASE=Database name;UID=Database UID;PWD=DatabasePasswd;')
Error:
Traceback (most recent call last): File "<stdin>", line 1, in
<module> pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver
Manager]Data source name not found, and no default driver specified
(0) (SQLDriverConnect)')
I am trying to solve this problem for last 3 days. But no luck yet. So any help/suggestion would be very helpful. I have already gone through googling. Thanks in advance :)