microsoft / mssql-django

The Microsoft Django backend for SQL Server provides a connectivity layer for Django on SQL Server or Azure SQL DB.
Other
324 stars 108 forks source link

Microsoft Django backend for SQL Server

Welcome to the MSSQL-Django 3rd party backend project!

mssql-django is a fork of django-mssql-backend. This project provides an enterprise database connectivity option for the Django Web Framework, with support for Microsoft SQL Server and Azure SQL Database.

We'd like to give thanks to the community that made this project possible, with particular recognition of the contributors: OskarPersson, michiya, dlo and the original Google Code django-pyodbc team. Moving forward we encourage partipation in this project from both old and new contributors!

We hope you enjoy using the MSSQL-Django 3rd party backend.

Features

Dependencies

Installation

  1. Install pyodbc 3.0 (or newer) and Django

  2. Install mssql-django:

    pip install mssql-django

  3. Set the ENGINE setting in the settings.py file used by your Django application or project to 'mssql':

    'ENGINE': 'mssql'

Configuration

Standard Django settings

The following entries in a database-level settings dictionary in DATABASES control the behavior of the backend:

and the following entries are also available in the TEST dictionary for any given database-level settings dictionary:

OPTIONS

Dictionary. Current available keys are:

Backend-specific settings

The following project-level settings also control the behavior of the backend:

Example

Here is an example of the database settings:

    DATABASES = {
        'default': {
            'ENGINE': 'mssql',
            'NAME': 'mydb',
            'USER': 'user@myserver',
            'PASSWORD': 'password',
            'HOST': 'myserver.database.windows.net',
            'PORT': '',

            'OPTIONS': {
                'driver': 'ODBC Driver 17 for SQL Server',
            },
        },
    }

    # set this to False if you want to turn off pyodbc's connection pooling
    DATABASE_CONNECTION_POOLING = False

Limitations

The following features are currently not fully supported:

JSONField lookups have limitations, more details here.

Contributing

More details on contributing can be found here.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Security Reporting Instructions

For security reporting instructions please refer to the SECURITY.md file in this repository.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.