Daksh Khot
Daksh Khot

Reputation: 59

django. Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')

Recieving this error when connecting to MSSQL server

My linux machines details:-

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:        14.04

MSSQL Server DB details:

version : 2012

Error:

 django.db.utils.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')

Python2.7

Driver: pyodbc == 3.0.10
django-pyodbc-azure == 1.8.3.0 django-mssql == 1.6.1 django >= 1.8.3

Upvotes: 2

Views: 1776

Answers (1)

FlipperPA
FlipperPA

Reputation: 14361

First, make sure you have the required packages installed (it looks like you may):

# Install pre-requesite packages
sudo apt-get install unixodbc unixodbc-dev freetds-dev freetds-bin tdsodbc

Then, make sure you have /etc/freetds/freetds.conf configured properly:

[global]
    # TDS protocol version, use:
    # 7.3 for SQL Server 2008 or greater (tested through 2014)
    # 7.2 for SQL Server 2005
    # 7.1 for SQL Server 2000
    # 7.0 for SQL Server 7
    tds version = 7.2
    port = 1433
    text size = 64512

# A typical Microsoft server
[dbserverdsn]
    host = dbserver.domain.com
    port = 1433
    tds version = 7.2

Next, make sure you have unixODBC talking correctly through FreeTDS in /etc/odbcinst.ini:

[FreeTDS]
Description = v0.91 with protocol v7.2
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

Finally, make sure /etc/odbc.ini sees the FreeTDS data source you created:

[dbserverdsn]
Driver = FreeTDS
Server = dbserver.domain.com
Port = 1433
TDS_Version = 7.2

If you have issues along the way, please try testing with the 'tsql' and 'isql' command line utilities and post any errors you receive. Hopefully, this works.

If the problem is with Django's configuration, please post your Django DATABASES settings for review.

Upvotes: 2

Related Questions