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

后端 未结 1 589
无人及你
无人及你 2021-01-28 00:47

I am trying to connect to SQL server 2012 using Pyodbc and Django framework.

But the version of Django is 2.1

相关标签:
1条回答
  • 2021-01-28 01:19

    As of today, django-pyodbc-azure supports Django 2.1. Below is my configuration.

    And here is the code that I used to configure the connection.

    DATABASES = {
    'default': {
        'ENGINE': "sql_server.pyodbc",
        'HOST': "server_name",
        'USER': "username",
        'PASSWORD': "password",
        'NAME': "database_name",
        'OPTIONS' : {
            'driver': 'ODBC Driver 13 for SQL Server',
        },
      }
    }
    

    Note: Don't use the IP address of the server as the HOST, instead use the computer name.

    0 讨论(0)
提交回复
热议问题