Package: django-pyodbc-azure
django-pyodbc-azureis a modern fork ofdjango-pyodbc, aDjangoMicrosoft SQL Server external
DB backend that uses ODBC by employing thepyodbclibrary. It supports
Microsoft SQL Server and Azure SQL Database.FeaturesSupports Django 2.1Supports Microsoft SQL Server 2008/2008R2, 2012, 2014, 2016, 2017 and
Azure SQL DatabasePasses most of the tests of the Django test suiteCompatible withMicosoft ODBC Driver for SQL Server,SQL Server Native Client,
andFreeTDSODBC driversDependenciesDjango 2.1pyodbc 3.0 or newerInstallationInstall pyodbc and DjangoInstall django-pyodbc-azurepip install django-pyodbc-azureNow you can point theENGINEsetting in the settings file used by
your Django application or project to the'sql_server.pyodbc'module path'ENGINE': 'sql_server.pyodbc'ConfigurationStandard Django settingsThe following entries in a database-level settings dictionary
in DATABASES control the behavior of the backend:ENGINEString. It must be"sql_server.pyodbc".NAMEString. Database name. Required.HOSTString. SQL Server instance in"server\instance"(on-premise) or"server.database.windows.net"(Azure SQL Database) format.PORTString. Server instance port.
An empty string means the default port.USERString. Database user name in"user"(on-premise) or"user@server"(Azure SQL Database) format.
If not given then MS Integrated Security will be used.PASSWORDString. Database user password.AUTOCOMMITBoolean. Set this to False if you want to disable
Django’s transaction management and implement your own.and the following entries are also available in the TEST dictionary
for any given database-level settings dictionary:NAMEString. The name of database to use when running the test suite.
If the default value (None) is used, the test database will use
the name “test_” +NAME.COLLATIONString. The collation order to use when creating the test database.
If the default value (None) is used, the test database is assigned
the default collation of the instance of SQL Server.DEPENDENCIESString. The creation-order dependencies of the database.
See the official Django documentation for more details.MIRRORString. The alias of the database that this database should
mirror during testing. Default value isNone.
See the official Django documentation for more details.OPTIONSDictionary. Current available keys are:driverString. ODBC Driver to use ("ODBC Driver 13 for SQL Server","SQL Server Native Client 11.0","FreeTDS"etc).
Default is"ODBC Driver 13 for SQL Server".isolation_levelString. Setstransaction isolation levelfor each database session. Valid values for this entry areREAD UNCOMMITTED,READ COMMITTED,REPEATABLE READ,SNAPSHOT, andSERIALIZABLE. Default isNonewhich means
no isolation levei is set to a database session and SQL Server default
will be used.dsnString. A named DSN can be used instead ofHOST.host_is_serverBoolean. Only relevant if using the FreeTDS ODBC driver under
Unix/Linux.By default, when using the FreeTDS ODBC driver the value specified in
theHOSTsetting is used in aSERVERNAMEODBC connection
string component instead of being used in aSERVERcomponent;
this means that this value should be the name of adataserverdefinition present in thefreetds.confFreeTDS configuration file
instead of a hostname or an IP address.But if this option is present and it’s value isTrue, this
special behavior is turned off.Seehttp://www.freetds.org/userguide/dsnless.htmfor more information.unicode_resultsBoolean. If it is set toTrue, pyodbc’sunicode_resultsfeature
is activated and strings returned from pyodbc are always Unicode.
Default value isFalse.extra_paramsString. Additional parameters for the ODBC connection. The format is"param=value;param=value".collationString. Name of the collation to use when performing text field
lookups against the database. Default isNone; this means no
collation specifier is added to your lookup SQL (the default
collation of your database will be used). For Chinese language you
can set it to"Chinese_PRC_CI_AS".connection_timeoutInteger. Sets the timeout in seconds for the database connection process.
Default value is0which disables the timeout.connection_retriesInteger. Sets the times to retry the database connection process.
Default value is5.connection_retry_backoff_timeInteger. Sets the back off time in seconds for reries of
the database connection process. Default value is5.query_timeoutInteger. Sets the timeout in seconds for the database query.
Default value is0which disables the timeout.backend-specific settingsThe following project-level settings also control the behavior of the backend:DATABASE_CONNECTION_POOLINGBoolean. If it is set toFalse, pyodbc’s connection pooling feature
won’t be activated.ExampleHere is an example of the database settings:DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'mydb',
        'USER': 'user@myserver',
        'PASSWORD': 'password',
        'HOST': 'myserver.database.windows.net',
        'PORT': '',

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

# set this to False if you want to turn off pyodbc's connection pooling
DATABASE_CONNECTION_POOLING = FalseLimitationsThe following features are currently not supported:Altering a model field from or to AutoField at migrationNoticeThis version ofdjango-pyodbc-azureonly supports Django 2.1.
If you want to use it on older versions of Django,
specify an appropriate version number (2.0.x.x for Django 2.0)
at installation like this:pip install "django-pyodbc-azure<2.1"