1. Thomas Hoffbauer
  2. django-mssql


django-mssql / docs / settings.txt



Please see the `Django documentation on DATABASES settings`_ for a complete 
list of available settings. `Django-mssql` builds upon these settings.
 .. _`Django documentation on DATABASES settings`: https://docs.djangoproject.com/en/1.4/ref/settings/#databases
This is an example of a typical configuration::

        'default': {
            'NAME': 'my_database',
            'ENGINE': 'sqlserver_ado',
            'HOST': 'dbserver\\ss2008',
            'USER': '',
            'PASSWORD': '',
            'OPTIONS' : {
                'provider': 'SQLOLEDB',
                'use_mars': True,


This value must be set to ``sqlserver_ado``.


Default: ``''``

This defines the Microsoft SQL Server to establish a connection. This value 
can be a hostname or IP address.


Default: ``''`` (Empty string)

This defines the network port to use when connecting to the server. If not 
defined, the standard Microsoft SQL Server port will be used.


This is the name of the SQL server database.


Default: ``''`` (Empty string)

This defines the name of the user to use when authenticating to the server.
When empty, a trusted connection (SSPI) will be used.


Default: ``''`` (Empty string)

When a `USER`_ is defined, this field should be the plain text password 
to use when authenticating.

.. note: 
    Any user or service that can read the configuration file can 
    will be able to see the plain-text password. Trusted connections are 


``Django-mssql`` provides a few extra ``OPTIONS`` that are specific to this
backend. Please note that while the main database settings are UPPERCASE
keys, the ``OPTIONS`` dictionary keys are expected to be lowercase (due to
legacy reasons).


Default: ``False``

Set to ``True`` to enable `Multiple Active Recordsets`. It is recommended 
to enable MARS to avoid seeing the "Cannot create new connection because 
in manual or distributed transaction mode" error.

.. note::
    This will only set the appropriate connection string value for 
    the "SQLOLEDB" provider. If you are using a different provider, you 
    will need to add the appropriate connection string value to 

.. _`extra_params`: OPTIONS-EXTRA_PARAMS


Default: ``''`` (Empty string)

This value will be appended to the generated connection string. Use this to
provide any specific connection settings that are not controllable with the
other settings.


Default: ``'SQLOLEDB'``

The SQL provider to use when connecting to the database.


Default: ``False``

This backend will automatically ``CAST`` fields used by the `AVG function`_ 
as ``FLOAT`` to match the behavior of the core database backends. Set this
to ``True`` if you need SQL server to retain the datatype of fields used
with ``AVG``.

.. versionadded:: 1.1

.. _`AVG function`: http://msdn.microsoft.com/en-us/library/ms177677.aspx

.. note::
    SQL server maintains the datatype of the values used in ``AVG``. The
    average of an ``int`` column will be an ``int``. With this option set
    to ``True``, ``AVG([1,2])`` == 1, not 1.5.