简体   繁体   English

将现有的MSSQL Server数据库连接到Django项目时出现问题。

[英]Problem connecting existing MSSQL server database to django project.

I need to connect a django project to an excisting MS SQL-Server database however I'm getting an error I don't understand: 我需要将django项目连接到现有的MS SQL-Server数据库,但是出现了我不明白的错误:

django.db.utils.InterfaceError: ('IM002', '[IM002] [Microsoft][Driver Manager ODBC] Nome origine dati non trovato e driver predefinito non specificato. (0) (SQLDriverConnect)')

English translation I found after googling this: 谷歌搜索后发现的英文翻译:

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

I have no idea what this means, however, I found this question which showed how to setup the DATABASES values in django. 我不知道这意味着什么,但是,我发现了这个问题该问题说明了如何在Django中设置DATABASES值。 Currently my DATABASES looks like this: 目前,我的DATABASES看起来像这样:

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': '<DATABASE NAME>',
        'HOST': '<PCNAME>\SQLEXPRESS',
        'USER': '<USERNAME>',
        'PASSWORD': '<PASSWORD>',
        'PORT': '',
        'OPTIONS': {
            'driver': 'SQL Native Client',
            'dsn': 'dsn_entry',
            'host_is_server': True
        }
    }
}

the server is on localhost and I'm using windows 7, django 2.1, python 3.7 and SQL Server 2014 Express 服务器位于localhost上,我使用的是Windows 7,django 2.1,python 3.7和SQL Server 2014 Express

What is this error and what am I doing wrong? 这是什么错误,我在做什么错?

A DSN is a pre-defined hostname and driver (and potentially other things) that are defined in a configuration file like ~/.odbc.ini. DSN是在〜/ .odbc.ini之类的配置文件中定义的预定义主机名和驱动程序(可能还有其他内容)。 change the driver inside the odbc.ini file. 更改odbc.ini文件中的驱动程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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