docs: def connect(dsn=None, database=None, user=None, password=None, timeout=None,
              login_timeout=15, as_dict=None,
              appname=None, port=None, tds_version=tds_base.TDS74,
              autocommit=False,
              blocksize=4096, use_mars=False, auth=None, readonly=False,
              load_balancer=None, use_tz=None, bytes_to_unicode=True,
              row_strategy=None, failover_partner=None, server=None,
              cafile=None, validate_host=True, enc_login_only=False,
              disable_connect_retry=False,
              pooling=False,
              ):
      """
      Opens connection to the database
  
      :keyword dsn: SQL server host and instance: <host>[\<instance>]
      :type dsn: string
      :keyword failover_partner: secondary database host, used if primary is not accessible
      :type failover_partner: string
      :keyword database: the database to initially connect to
      :type database: string
      :keyword user: database user to connect as
      :type user: string
      :keyword password: user's password
      :type password: string
      :keyword timeout: query timeout in seconds, default 0 (no timeout)
      :type timeout: int
      :keyword login_timeout: timeout for connection and login in seconds, default 15
      :type login_timeout: int
      :keyword as_dict: whether rows should be returned as dictionaries instead of tuples.
      :type as_dict: boolean
      :keyword appname: Set the application name to use for the connection
      :type appname: string
      :keyword port: the TCP port to use to connect to the server
      :type port: int
      :keyword tds_version: Maximum TDS version to use, should only be used for testing
      :type tds_version: int
      :keyword autocommit: Enable or disable database level autocommit
      :type autocommit: bool
      :keyword blocksize: Size of block for the TDS protocol, usually should not be used
      :type blocksize: int
      :keyword use_mars: Enable or disable MARS
      :type use_mars: bool
      :keyword auth: An instance of authentication method class, e.g. Ntlm or Sspi
      :keyword readonly: Allows to enable read-only mode for connection, only supported by MSSQL 2012,
        earlier versions will ignore this parameter
      :type readonly: bool
      :keyword load_balancer: An instance of load balancer class to use, if not provided will not use load balancer
      :keyword use_tz: Provides timezone for naive database times, if not provided date and time will be returned
        in naive format
      :keyword bytes_to_unicode: If true single byte database strings will be converted to unicode Python strings,
        otherwise will return strings as ``bytes`` without conversion.
      :type bytes_to_unicode: bool
      :keyword row_strategy: strategy used to create rows, determines type of returned rows, can be custom or one of:
        :func:`tuple_row_strategy`, :func:`list_row_strategy`, :func:`dict_row_strategy`,
        :func:`namedtuple_row_strategy`, :func:`recordtype_row_strategy`
      :type row_strategy: function of list of column names returning row factory
      :keyword cafile: Name of the file containing trusted CAs in PEM format, if provided will enable TLS
      :type cafile: str
      :keyword validate_host: Host name validation during TLS connection is enabled by default, if you disable it you
        will be vulnerable to MitM type of attack.
      :type validate_host: bool
      :keyword enc_login_only: Allows you to scope TLS encryption only to an authentication portion.  This means that
        anyone who can observe traffic on your network will be able to see all your SQL requests and potentially modify
        them.
      :type enc_login_only: bool
      :returns: An instance of :class:`Connection`
      """
      login = _TdsLogin()
      login.client_host_name = socket.gethostname()[:128]
      login.library = "Python TDS Library"
      login.user_name = user or ''
      login.password = password or ''
      login.app_name = appname or 'pytds'
      login.port = port
      login.language = ''  # use database default
      login.attach_db_file = ''
      login.tds_version = tds_version
      if tds_version < tds_base.TDS70:
          raise ValueError('This TDS version is not supported')
      login.database = database or ''
      login.bulk_copy = False
      login.client_lcid = lcid.LANGID_ENGLISH_US
      login.use_mars = use_mars
      login.pid = os.getpid()
      login.change_password = ''
      login.client_id = uuid.getnode()  # client mac address
      login.cafile = cafile
      login.validate_host = validate_host
      login.enc_login_only = enc_login_only
      if cafile:
          if not tls.OPENSSL_AVAILABLE:
              raise ValueError("You are trying to use encryption but pyOpenSSL does not work, you probably "
                               "need to install it first")
          login.tls_ctx = tls.create_context(cafile)
          if login.enc_login_only:
              login.enc_flag = PreLoginEnc.ENCRYPT_OFF
          else:
              login.enc_flag = PreLoginEnc.ENCRYPT_ON
      else:
          login.tls_ctx = None
          login.enc_flag = PreLoginEnc.ENCRYPT_NOT_SUP
  
      if use_tz:
          login.client_tz = use_tz
      else:
          login.client_tz = pytds.tz.local
  
      # that will set:
      # ANSI_DEFAULTS to ON,
      # IMPLICIT_TRANSACTIONS to OFF,
      # TEXTSIZE to 0x7FFFFFFF (2GB) (TDS 7.2 and below), TEXTSIZE to infinite (introduced in TDS 7.3),
      # and ROWCOUNT to infinite
      login.option_flag2 = tds_base.TDS_ODBC_ON
  
      login.connect_timeout = login_timeout
      login.query_timeout = timeout
      login.blocksize = blocksize
      login.auth = auth
      login.readonly = readonly
      login.load_balancer = load_balancer
      login.bytes_to_unicode = bytes_to_unicode
  
      if server and dsn:
          raise ValueError("Both server and dsn shouldn't be specified")
  
      if server:
          warnings.warn("server parameter is deprecated, use dsn instead", DeprecationWarning)
          dsn = server
  
      if load_balancer and failover_partner:
          raise ValueError("Both load_balancer and failover_partner shoudln't be specified")
      if load_balancer:
          servers = [(srv, None) for srv in load_balancer.choose()]
      else:
          servers = [(dsn or 'localhost', port)]
          if failover_partner:
              servers.append((failover_partner, port))
  
      parsed_servers = []
      for srv, port in servers:
          host, instance = _parse_server(srv)
          if instance and port:
              raise ValueError("Both instance and port shouldn't be specified")
          parsed_servers.append((host, port, instance))
  
      login.servers = _get_servers_deque(tuple(parsed_servers), database)
  
      # unique connection identifier used to pool connection
      key = (
          dsn,
          login.user_name,
          login.app_name,
          login.tds_version,
          login.database,
          login.client_lcid,
          login.use_mars,
          login.cafile,
          login.blocksize,
          login.readonly,
          login.bytes_to_unicode,
          login.auth,
          login.client_tz,
          autocommit,
      )
  
      conn = Connection()
      conn._use_tz = use_tz
      conn._autocommit = autocommit
      conn._login = login
      conn._pooling = pooling
      conn._key = key
  
      assert row_strategy is None or as_dict is None,\
          'Both row_startegy and as_dict were specified, you should use either one or another'
      if as_dict is not None:
          conn.as_dict = as_dict
      elif row_strategy is not None:
          conn._row_strategy = row_strategy
      else:
          conn._row_strategy = tuple_row_strategy # default row strategy
  
      conn._isolation_level = 0
      conn._dirty = False
      from .tz import FixedOffsetTimezone
      conn._tzinfo_factory = None if use_tz is None else FixedOffsetTimezone
      if disable_connect_retry:
          conn._try_open(timeout=login.connect_timeout)
      else:
          conn._open()
      return conn