# Django3.0+ connects to SQL Server

**URL:** https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796
**Category:** Using Django
**Created:** [June 4, 2020, 7:47am UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796 "2020-06-04T07:47:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![JingChaoLiang](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@JingChaoLiang](https://forum.djangoproject.com/u/JingChaoLiang)
#### Post date: [June 4, 2020, 7:47am UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796/1 "2020-06-04T07:47:35Z")

</div>

What should I do to make Django3.0+ connects to SQL Server?  
When I follow “[https://pypi.org/project/django-mssql-backend/](https://pypi.org/project/django-mssql-backend/)” step by step, It tells me that it can support Django 2.2, 3.0 and depend on Django 2.2 or newer.  
But When I follow “[https://pypi.org/project/django-pyodbc-azure/](https://pypi.org/project/django-pyodbc-azure/)” to install “django-pyodbc-azure” ,It tells me that it just supports Django 2.1.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/d/d52e800c4f1e7e48e4e5b213b1d2e4382fc74c03.png)  
So,how can I do now?Can someone help me?!!!

---

<div class="post-metadata">

### Author: ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)
#### Post date: [June 4, 2020, 8:07am UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796/2 "2020-06-04T08:07:05Z")

</div>

You only one of them. Try django-mssql-backend ?

---

<div class="post-metadata">

### Author: ![JingChaoLiang](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@JingChaoLiang](https://forum.djangoproject.com/u/JingChaoLiang)
#### Post date: [June 4, 2020, 8:14am UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796/3 "2020-06-04T08:14:26Z")

</div>

I have tried django-mssql-backend only,but it said I should install django-pyodbc-azure.  
And I also tried django-pyodbc-azure only,it was a definite failure…

---

<div class="post-metadata">

### Author: ![JingChaoLiang](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@JingChaoLiang](https://forum.djangoproject.com/u/JingChaoLiang)
#### Post date: [June 4, 2020, 8:21am UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796/4 "2020-06-04T08:21:10Z")

</div>

My installation records and Settings are as follows:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/8/87fca1fabe424881a8f558ec294f39999142e756.png)

---

<div class="post-metadata">

### Author: ![chriswedgwood](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@chriswedgwood](https://forum.djangoproject.com/u/chriswedgwood)
#### Post date: [June 4, 2020, 12:24pm UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796/5 "2020-06-04T12:24:10Z")

</div>

Hi

Are you running django in a virtual environment? I created a virtual environment in windows and ran pip install django-mssql-backend and I ran pip freeze after which showed me that pyodbc was installed so your pyodbc error suggests you are not?

---

<div class="post-metadata">

### Author: ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)
#### Post date: [June 4, 2020, 3:54pm UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796/6 "2020-06-04T15:54:54Z")

</div>

The django-mssql-backend docs say:

> _django-mssql-backend_ is a fork of [django-pyodbc-azure](https://pypi.org/project/django-pyodbc-azure/)

A “fork” is an updated copy. Therefore you should only install django-mssql-backend. If you installed django-pyodbc-azure, you should try uninstalling both of them then installing only django-mssql-backend.

django-mssql-backend’s installation instructions say:

> Installation
> 
> 1. Install pyodbc and Django
> 2. Install django-mssql-backend

You’re seeing this error:

> Error loading pyodbc module: No module named ‘pyodbc’

This means that you haven’t installed pyodbc as per step 1.

That library is here: [pyodbc · PyPI](https://pypi.org/project/pyodbc/)

I think if you `pip install pyodbc` it should work.

@chriswedgwood is correct - installing django-mssql-backend should install pyodbc automatically. This is because it’s in its `install_requires` declaration: [https://github.com/ESSolutions/django-mssql-backend/blob/master/setup.py#L27](https://github.com/ESSolutions/django-mssql-backend/blob/master/setup.py#L27) .

---

<div class="post-metadata">

### Author: ![JingChaoLiang](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@JingChaoLiang](https://forum.djangoproject.com/u/JingChaoLiang)
#### Post date: [June 5, 2020, 1:20am UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796/7 "2020-06-05T01:20:14Z")

</div>

I’m running diango in my desktop.Adopted @adamchainz’s suggestion,which try uninstalling both of them then installing only django-mssql-backend,it works!

---

<div class="post-metadata">

### Author: ![JingChaoLiang](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@JingChaoLiang](https://forum.djangoproject.com/u/JingChaoLiang)
#### Post date: [June 5, 2020, 1:21am UTC](https://forum.djangoproject.com/t/django3-0-connects-to-sql-server/2796/8 "2020-06-05T01:21:17Z")

</div>

It works!!! Thank a lot.
