Get Django to support Sql Server as a back end database

  • 2020-09-28 08:59:57
  • OfStack

I haven't written python in windows for a long time. This is not a problem, python well, as long as the system is installed, then most of the code will work. However, sometimes it is necessary to call one of Microsoft's specific API, Java, python, etc.

Today I moved the Django project I wrote in Mac to win10. I used sqlite3 as the backend database, but the company required me to use SQL Server when the project was officially launched. Therefore, I remember that django 1.9 does not support Microsoft by default, so I began to search and search on the Internet. Now I found that someone said that as long as you install a package named pymssql, so I installed it.


pip install pymssql 

Well, I was very happy that it was installed, and after setting the parameters of the database, I excitedly ran python ES21en.py makemigrations

However.. No, no module named sqlserver_ado

So I had another random search, and someone said to install ES33en-ES34en. Well, this time there is the key word django, which must be reliable.


pip install django-sqlserver 

After installing, I'm still running makemigrations. This time there is no last error message. Then there is "no module named xxx.backends.util", what the hell is that!!

I went to ask Google and Google said that my VERSION of django was too high and needed to be reduced. So I reduced django to 1.8, no. I got it down to 1.7 again, but it still doesn't work. I was cruel to reduce it to 1.6, only to find that even the es52EN1.9 program is not supported. Ah..

However, some people on Google said that django1.9 could support SQL Server through some strange trick, so I searched again and saw that the bag of ES59en-ES60en-ES61en seemed to support django1.9, so I got down and tried. Not t much hope, though, as the bag doesn't even have an sql in its name.


pip install django-pyodbc-azure 

After I installed it, I ran python ES68en.py makemigrations, and it worked. I opened database 1 and saw that the various tables had been set up. After a few operations, I was relieved to find that the data was being read and written normally.


Related articles: