michiya / django-pyodbc-azure

Django backend for Microsoft SQL Server and Azure SQL Database using pyodbc
https://pypi.python.org/pypi/django-pyodbc-azure
BSD 3-Clause "New" or "Revised" License
321 stars 140 forks source link

The database driver doesn't support modern datatime types. #185

Open tbenny opened 6 years ago

tbenny commented 6 years ago

When we use Freetds and unixodbc with pyodbc-azure package in our Django application , we are getting the error while connecting to MSSql Server 2016 django.core.exceptions.ImproperlyConfigured: The database driver doesn't support modern datatime types.

Our settings.py is as follows

DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'quickstartdb', 'USER': 'xx', 'PASSWORD': 'password', 'HOST': '192.xxx.xx.xx', 'PORT': '1433', 'OPTIONS': {

'AUTOCOMMIT': True,

        'host_is_server': True,
        'unicode_results': True,
        'driver': 'FreeTDS',
    },
},

}

Our ubuntu version is 18.10

wil commented 5 years ago

Could the issue be the TDS version used? According to this FreeTDS page you need to be using TDS version 7.3 and above in order to support DATETIME2, etc. I have not tested it, but it may be worth trying the following:

'OPTIONS': {
    'host_is_server': True,
    'unicode_results': True,
    'driver': 'FreeTDS',
    'extra_params': "TDS_VERSION=7.3",  # force the TDS version to 7.3 or 7.4 or 8.0
},
nadyr-mg commented 5 years ago

@wil I had the same problem, so I was searching for an answer for a whole day. You saved my life, thank you! ('extra_params' option solved the issue)

wil commented 5 years ago

I'm glad it helped @marshygeek. @tbenny have you tried the extra_params option?