没有名为sql_server.pyodbc.base的模块 [英] No module named sql_server.pyodbc.base

查看:182
本文介绍了没有名为sql_server.pyodbc.base的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用SQL Server作为Django的后端,但是在调试Web项目时得到了这个。 sql_server.pyodbc不是可用的数据库后端。错误是:没有名为sql_server.pyodbc.base的模块。

I wanted to use SQL Server as the backend for Django, but I got this when debugging the web project. 'sql_server.pyodbc' isn't an available database backend. Error was: No module named sql_server.pyodbc.base.

Python环境(Python 2.7)与Django(1.7),pyodbc(3.0.10),pywin32(218.3) 。这是我的settings.py:

Python Environments (Python 2.7) with Django (1.7), pyodbc(3.0.10), pywin32(218.3). And here is my settings.py:

DATABASES = {
'default': {
    'ENGINE': 'sql_server.pyodbc',
    'NAME': 'DatabaseName',
    'USER': 'user',
    'PASSWORD': 'pwd',
    'HOST': '127.0.0.1',
    'PORT': '',
    'OPTIONS': {
        'driver': 'SQL Server Native Client 11.0',
        'server': 'ServerName',
        'MARS_Connection': True,
        'dsn': 'MSSQL-PYTHON',
        },
    }
}


推荐答案

您尚未安装具有所需数据库后端的软件包。

You have not installed the package with the required DB backend.

执行:

pip install django-pyodbc
pip install django-pyodbc-azure

请参阅此文档

第二个链接中的数据库设置示例:

An example of the database settings from the second link:

DATABASES = {
'default': {
    'ENGINE': 'sql_server.pyodbc',
    'NAME': 'mydb',
    'USER': 'user@myserver',
    'PASSWORD': 'password',
    'HOST': 'myserver.database.windows.net',
    'PORT': '',

    'OPTIONS': {
        'driver': 'SQL Server Native Client 11.0',
    },
  },
}

#set this to `False` if you want to turn off pyodbc's connection pooling:
DATABASE_CONNECTION_POOLING = False

这篇关于没有名为sql_server.pyodbc.base的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆