Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Sql Server with Django in production

Has anybody got recent experience with deploying a Django application with an SQL Server database back end? Our workplace is heavily invested in SQL Server and will not support Django if there isn't a sufficiently developed back end for it.

I'm aware of mssql.django-pyodbc and django-mssql as unofficially supported back ends. Both projects seem to have only one person contributing which is a bit of a worry though the contributions seem to be somewhat regular.

Are there any other back ends for SQL Server that are well supported? Are the two I mentioned here 'good enough' for production? What are your experiences?

like image 562
Josh Smeaton Avatar asked May 09 '09 06:05

Josh Smeaton


People also ask

Can I use SQL Server with Django?

Django has a built-in web server that is used for development purposes. The framework supports several database management systems including Microsoft SQL Server.

Can Django be used in production?

If you want to run Django in production, be sure to use a production-ready web server like Nginx, and let your app be handled by a WSGI application server like Gunicorn. If you plan on running on Heroku, a web server is provided implicitly. You don't have to take care of it.

Which SQL is best for Django?

PostgreSQL notes. Django supports PostgreSQL 11 and higher. psycopg2 2.8. 4 or higher is required, though the latest release is recommended.

Can I use SQLite in production Django?

Long answer: It is said you can't use SQLite in production because it doesn't support concurrency (no more than one user can be writing to the database at the same time) and it can't scale. But let's be pragmatic. Many applications are used only by a few users.


2 Answers

As has been stated, django-pyodbc is a good way to go. PyODBC is probably the most mature SQL Server library for Python there is.

The only thing you may have problems with is that pyodbc doesn't support stored procedures very well (you can call them, but you have no way to get results from them). You can call them using pymssql, but I would avoid it if at all possible as it doesn't support the standard DB-API interface and may be subject to changes. If you need to do this, your best bet is to use adodbapi directly (it's included with the python win32 package, which you'll probably end up installing anyway).

like image 180
Jason Baker Avatar answered Sep 22 '22 00:09

Jason Baker


These days

  • django-mssql: resulted in error "NoneType not callable" upon ./manage.py migrate
  • avidal/django-pyodbc: unmaintained. Replaced by:
    • django-pyodbc: no support for python 3
    • django-pyodbc-azure: works for me so far
      • EDIT: Seems to be unmaintained. Filed issue 125 asking about status
      • EDIT: got reply from maintainer. Will be made up-to-date with Django 2.0 soon
      • EDIT: maintainer released version 2.0 for django 2.0
      • EDIT: maintainer released version 2.1 for django 2.1

EDIT: Here are the package versions

Django==1.11.6 django-mssql==1.8 pyodbc==4.0.19 django-pyodbc==1.1.1 django-pyodbc-azure==1.11.0.0 
like image 22
Shadi Avatar answered Sep 20 '22 00:09

Shadi