简体   繁体   中英

django.db.utils.InterfaceError:('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) )

I have a Django web app with azure sql server,i move the code from one laptop to another and suddenly i got django.db.utils.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)') imidatly after starting the web server

I have been able to isolate the problem, and realized it coming from the db connection in setting.py, i tried to run simple python quay from the console and it worked

I compared my settings in the ODBC data source to my old laptop and it looks the same,

SOLVED-- i noticed that only diffrence was that in my old laptop i have also ODBC Driver 13 for SQL Server, i installed this as well and it worked

I am using: Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information. Any ideas?

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'XXXXXX',
        'Trusted_Connection':'No',       
        'HOST' : 'XXXXXXXXXXX',
        'DRIVER': '{ODBC Driver 17 for SQL Server}',
        'OPTIONS': {
            'extra_params': 'APP=Setting.py',
        },
        'AUTOCOMMIT' : True ,
        'USER' : 'XXXXXXX',
        'PASSWORD' : 'XXXXXXX'
          }}

I needed to install https://www.microsoft.com/en-us/download/details.aspx?id=56567 odbc my SQL 17 driver.

Instead of

'DRIVER': '{ODBC Driver 17 for SQL Server}',

use

'DRIVER': 'SQL Server Native Client 11.0',

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM