Connect to MS SQL database using freetds, unixodbc and python

Having trouble connecting to a MS SQL database. The OS I'm running is opensuse 13.1 64bit. I've manage to run both tsql and isql successfully. However, when I try to connect via python I get the following error message:

cx = pyodbc.connect('DSN=fdd-11;DATABASE=OD_STAGING;UID=SQL_USR_RO;PWD=test_RO!')

Traceback (most recent call last):
File "", line 1, in
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')

The configuration files are as follows:

:/etc/unixODBC/odbc.ini

[newserver-fdd-11]
Driver=FreeTDS
Servername=newserver-fdd-11
Trace=No
Database=OD_STAGING

[fdd-11]
Driver=FreeTDS
TDS_Version=11
Description=Production Flight Database Server
Server=newserver-fdd-11
Port=1433
Database=OD_STAGING

:/etc/unixODBC/odbcinst.ini

[SQL Server]
Description=FreeTDS unixODBC Driver
Driver=/usr/lib64/libtdsodbc.so.0
Setup=/usr/lib64/libtdsodbc.so.0
UsageCount=2

[FreeTDS]
Description=TDS driver (Sybase/MS SQL)
Driver=/usr/lib64/libtdsodbc.so.0
UsageCount=8

/etc/freetds.conf

; debug flags = 0xffff

Command and connection timeouts
; timeout = 10
; connect timeout = 10

//If you get out-of-memory errors, it may mean that your client
//is trying to allocate a huge buffer for a TEXT field.
//Try setting 'text size' to a more reasonable limit
text size = 64512

A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0

A typical Microsoft server
[newserver-fdd-11]

host = 10.21.4.70
port = 1433
tds version = 11.0

1 answer

After installing a Microsoft provided driver and getting the same result I then tried another version of Python and isolated the problem.

First Environment

:/etc/ODBCDataSources> /usr/bin/python

Python 2.7.6 (default, Nov 21 2013, 15:55:38) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Type "help", "copyright", "credits" or "license" for more information.

import pyodbc
cnxn = pyodbc.connect('DSN=fdd-11;UID=USR_RO;PWD=test_RO!')    "No Error"

Second Environment

:/etc/ODBCDataSources> python

Enthought Canopy Python 2.7.6 | 64-bit | (default, Jun 4 2014,

cnxn = pyodbc.connect('DSN=fdd-11;UID=USR_RO;PWD=test_RO!')    "Error Below"

Traceback (most recent call last):
File "", line 1, in
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')