Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Sql Server with Django 2.0

I would like to use Django 2.0 with legacy MS SQL Server database.

Latest information regarding usage Django with MS SQL Server i could find is Using Sql Server with Django in production/These days and it is about Django 1.11 Most supported seems django-pyodbc-azure but it's not supporting Django 2.0 yet: django-pyodbc-azure issue #124

Is there any alternative?

like image 389
Frane Avatar asked Jan 05 '18 11:01

Frane


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.

Which database is best for Django?

Django officially supports the following databases: PostgreSQL. MariaDB. MySQL.

Does Django use ODBC?

django-pyodbc is a Django SQL Server DB backend powered by the pyodbc library. pyodbc is a mature, viable way to access SQL Server from Python in multiple platforms and is actively maintained. It's also used by SQLAlchemy for SQL Server connections.

Can I use Microsoft SQL Server with Python?

You can connect to a SQL Database using Python on Windows, Linux, or macOS.


1 Answers

Found the solution and post it if anyone facing same problem.

I used django-pyodbc-azure 2.0.4.1 in my Django 2.0.4

The settings that worked for me:

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'dbName',
        'USER': 'yourUserName',
        'PASSWORD': 'yourPassword',
        'HOST': '(local)',
        'PORT': '',
        'OPTIONS': {
            'driver': 'ODBC Driver 11 for SQL Server',
        },
    }
}
like image 182
Ryan Avatar answered Oct 19 '22 01:10

Ryan