1

I am trying the connect the MSSQL server and pull the data from the SQL server.

I landed on below error.

"django.core.exceptions.ImproperlyConfigured: The database driver doesn't support modern datatime types."

Version: Django: 2.2 Python: 3.7 django-pyodbc-azure-2.1.0.0 pyodbc-4.0.26

 DATABASES = {
     'default': {
         'ENGINE': 'sql_server.pyodbc',
         'HOST': 'server\\DB',
         'NAME': 'Archive',
         'USER': 'Admin',
         'PASSWORD': '*****',
         'PORT': '49422',

         'OPTIONS': {
             'driver': 'SQL Server',
             'dsn': 'Django',
             'extra_params': "Persist Security Info=False;server=server\\DB",
         },
     }
 }
Dale K
  • 25,246
  • 15
  • 42
  • 71
  • The "SQL Server" ODBC driver that ships with windows is a legacy one that shouldn't be used for new development. Try the newer ["ODBC Driver 17 for SQL Server"](https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-2017). – Dan Guzman Apr 22 '19 at 10:48

1 Answers1

3

The "SQL Server" ODBC driver that ships with windows is unaware of SQL Server data types introduced after SQL Server 2000 (e.g. date, time, datetime2, datetimeoffset). It is intended only for legacy applications and shouldn't be used for new development.

Instead, download and install the separately distributed ODBC driver. In addition to supporting newer data types, the newer drivers support TLS protocol enhancements and encryption features. The current ODBC driver as of this writing is the ODBC Driver 17 for SQL Server.

Dan Guzman
  • 43,250
  • 3
  • 46
  • 71