Opened 4 years ago

Closed 4 years ago

#29659 closed Uncategorized (invalid)

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

Reported by: Gurmeet Kaur Owned by: nobody
Component: Database layer (models, ORM) Version: 2.1
Severity: Normal Keywords:
Cc: gurmeet.kaur@…, gurmeetkaurjuneja23@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

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?

Change History (1)

comment:1 Changed 4 years ago by Tim Graham

Description: modified (diff)
Resolution: invalid
Status: newclosed

See TicketClosingReasons/UseSupportChannels for places to get help with usage questions like this.

Note: See TracTickets for help on using tickets.
Back to Top