8
votes

I would like to use Django 2.0 with legacy MS SQL Server database.

Latest information regarding usage Django with MS SQL Server i could find is Using Sql Server with Django in production/These days and it is about Django 1.11 Most supported seems django-pyodbc-azure but it's not supporting Django 2.0 yet: django-pyodbc-azure issue #124

Is there any alternative?

2
Would you please share your configuration and error trace?Jay Gong
I tried pip install django-pyodbc-azure but it want's to downgrade Django to 1.11, so I canceled it.Frane
Would love to know how you resolve this... would rather not downgrade...Matthew Clark

2 Answers

12
votes

Found the solution and post it if anyone facing same problem.

I used django-pyodbc-azure 2.0.4.1 in my Django 2.0.4

The settings that worked for me:

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'dbName',
        'USER': 'yourUserName',
        'PASSWORD': 'yourPassword',
        'HOST': '(local)',
        'PORT': '',
        'OPTIONS': {
            'driver': 'ODBC Driver 11 for SQL Server',
        },
    }
}
0
votes

I was facing same error of ODBC Driver Manager

django.db.utils.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manag er] Data source name not found and no default driver specified (0) (SQLDriverCon nect)')

Solution: When i added below code in database connection, then my error fixed.
'OPTIONS': { 'host_is_server': True, 'driver': 'ODBC Driver 11 for SQL Server', }