There is no module named sql_server.pyodbc.base

I wanted to use SQL Server as the backend for Django, but I got this when debugging a web project. "sql_server.pyodbc" is not an available database backend. Error: There is no module named sql_server.pyodbc.base.

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

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', }, } } 
+5
source share
2 answers

You have not installed the package with the required database.

Do:

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

See the doc and this one .

An example of 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 connection pooling: DATABASE_CONNECTION_POOLING = False 
+10
source

Check out this link :

 DATABASES = { 'default': { 'NAME': 'my_database', 'ENGINE': 'sqlserver_ado', 'HOST': 'dbserver\\ss2008', 'USER': '', 'PASSWORD': '', } } 

Presumably you can use SQL Server with Django MSSQL (link above). you can check the [Django] documentation to find out which database support django supports "natively". ( https://docs.djangoproject.com/en/1.8/ref/settings/#databases )

0
source

Source: https://habr.com/ru/post/1232119/


All Articles