<commit_before>"""Microsoft SQL Server database backend for Django."""
from __future__ import absolute_import, unicode_literals
import datetime
import collections

import django.db.backends.base.client
from django.utils.timezone import utc

import sqlserver_ado
import sqlserver_ado.base
import sqlserver_ado.compiler
import sqlserver_ado.operations
import sqlserver_ado.introspection
import sqlserver_ado.creation

try:
    import pytds
except ImportError:
    raise Exception('pytds is not available, to install pytds run pip install python-tds')

try:
    import pytz
except ImportError:
    pytz = None

DatabaseError = pytds.DatabaseError
IntegrityError = pytds.IntegrityError


_SUPPORTED_OPTIONS = ['failover_partner']


def utc_tzinfo_factory(offset):
    if offset != 0:
        raise AssertionError("database connection isn't set to UTC")
    return utc


#
# Main class which uses pytds as a driver instead of adodb
#
class DatabaseWrapper(sqlserver_ado.base.DatabaseWrapper):
    Database = pytds

    def get_connection_params(self):
        """Returns a dict of parameters suitable for get_new_connection."""
        from django.conf import settings
        settings_dict = self.settings_dict
        options = settings_dict.get('OPTIONS', {})
        autocommit = options.get('autocommit', False)
        conn_params = {
            'server': settings_dict['HOST'],
            'database': settings_dict['NAME'],
            'user': settings_dict['USER'],
            'port': settings_dict.get('PORT', '1433'),
            'password': settings_dict['PASSWORD'],
            'timeout': self.command_timeout,
            'autocommit': autocommit,<commit_msg>Add support for all kwargs in pytds.connect (#23)<commit_after>"""Microsoft SQL Server database backend for Django."""
from __future__ import absolute_import, unicode_literals
import datetime
import collections

import django.db.backends.base.client
from django.utils.timezone import utc

import sqlserver_ado
import sqlserver_ado.base
import sqlserver_ado.compiler
import sqlserver_ado.operations
import sqlserver_ado.introspection
import sqlserver_ado.creation

try:
    import pytds
except ImportError:
    raise Exception('pytds is not available, to install pytds run pip install python-tds')

try:
    import pytz
except ImportError:
    pytz = None

DatabaseError = pytds.DatabaseError
IntegrityError = pytds.IntegrityError


_SUPPORTED_OPTIONS = [
    'dsn', 'timeout',
    'login_timeout', 'as_dict',
    'appname', 'tds_version',
    'blocksize', 'auth',
    'readonly', 'bytes_to_unicode',
    'row_strategy', 'cafile',
    'validate_host', 'enc_login_only',
]


def utc_tzinfo_factory(offset):
    if offset != 0:
        raise AssertionError("database connection isn't set to UTC")
    return utc


#
# Main class which uses pytds as a driver instead of adodb
#
class DatabaseWrapper(sqlserver_ado.base.DatabaseWrapper):
    Database = pytds

    def get_connection_params(self):
        """Returns a dict of parameters suitable for get_new_connection."""
        from django.conf import settings
        settings_dict = self.settings_dict
        options = settings_dict.get('OPTIONS', {})
        autocommit = options.get('autocommit', False)
        conn_params = {
            'server': settings_dict['HOST'],
            'database': settings_dict['NAME'],
            'user': settings_dict['USER'],
            'port': settings_dict.get('PORT', '1433'),
            'password': settings_dict['PASSWORD'],
            'timeout': self.command_timeout,
            'autocommit': autocommit,
{'fraction_non_alphanumeric': 0.09398601398601399, 'fraction_numerical': 0.0033566433566433566, 'mean_word_length': 3.7301587301587302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '609954', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1018, 'n_words': 279}