2

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I am able to talk to my database using tsql. Does it mean everything is configured correctly on the FreeTDS side? I am still getting the error in the original question.
I'd create a new question with as many details as you can provide. tsql just checks to see if FreeTDS is working, but not unixODBC, pyodbc or other parts of the stack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.