sql-serverdjangopyodbcdjango-pyodbc-azure

Can't connect to MSSQL using django-pyodbc-azure 2.1.0.0


As the title says. Im getting this error

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

Heres my code

DATABASES = {
'default': {
    'ENGINE': 'sql_server.pyodbc',
    'NAME': 'dbname',
    'USER': 'user',
    'PASSWORD': 'password',
    'HOST': 'HOST',
    'PORT': '',

    'OPTIONS': {
        'driver': 'ODBC Driver 13 for SQL Server',
    },

}
}
DATABASE_CONNECTION_POOLING = False

Solution

  • Check first if you have that driver installed:

    import pyodbc
    print(pyodbc.drivers())
    

    Download ODBC Driver for SQL Server

    Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS