Not able to connect to SQL Server 2012 from current version of DJango and Python

18 views
Skip to first unread message

Gurmeet Kaur

unread,
Aug 10, 2018, 1:43:52 PM8/10/18
to django...@googlegroups.com
Hi All,

I am trying to connect to SQL server 2012 using Pyodbc and DJango framework but the version of Django is 2.1. Now, when I try to connect using below code when I only have Pyodbc installed then the below code doesnot run.

DATABASES = {
    'default': {
        # 'ENGINE': '{ODBC Driver 11 for SQL Server}', Tried this as well but it did not work.
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'MY_DATABASE',
        # 'HOST': 'XXX.XX.XXX.XXX', Tried this as well but it did not work.
        'SERVER': 'XXX.XX.XXX.XXX',
        # 'HOST': 'SQLSERVER_InstanceName',
        'PORT': '',
        'USER': 'SQLSERVERUSER',
        'PASSWORD': 'USER's PASSWORD',
         'DATABASE': 'MY_DATABASE',
         # 'Trusted_Connection': 'Yes',
        # 'OPTIONS': {
        #             'driver': 'ODBC Driver 11 for SQL Server',
        #            }

            },
}


But when I install django-pyodbc-azure and try to run the above code by running python manage.py inspectdb command, it works.

But the problem with using django-pyodbc-azure is that it downgrades the current version of django to 2.0.8 version - which I do not want.

I do not want to use FreeTDS or Pymssql. I want to go with pyodbc only.

Can someone please suggest some way for this?


Thanks,
Gurmeet Kaur

Jason

unread,
Aug 11, 2018, 7:16:23 AM8/11/18
to Django users
the dev for that library has specified that this is not compatible with django 2.1.  so your options are to either find another connector library compatible with 2.1 or downgrade to using 2.0.x

https://github.com/michiya/django-pyodbc-azure/blob/azure-2.0/setup.py#L29
Reply all
Reply to author
Forward
0 new messages