def connect(host='localhost', port=21050, protocol='hiveserver2', database=None, timeout=45, use_ssl=False, ca_cert=None, use_ldap=False, ldap_user=None, ldap_password=None, use_kerberos=False, kerberos_service_name='impala'): # PEP 249 if protocol.lower() == 'beeswax': warn_deprecate_hs2() service = connect_to_beeswax(host, port, timeout, use_ssl, ca_cert, use_ldap, ldap_user, ldap_password, use_kerberos, kerberos_service_name) return BeeswaxConnection(service, default_db=database) elif protocol.lower() == 'hiveserver2': service = connect_to_hiveserver2(host, port, timeout, use_ssl, ca_cert, use_ldap, ldap_user, ldap_password, use_kerberos, kerberos_service_name) return HiveServer2Connection(service, default_db=database) else: raise NotSupportedError( "The specified protocol '%s' is not supported." % protocol)
def connect(host='localhost', port=21050, protocol=None, database=None, timeout=None, use_ssl=False, ca_cert=None, auth_mechanism='NOSASL', user=None, password=None, kerberos_service_name='impala', use_ldap=None, ldap_user=None, ldap_password=None, use_kerberos=None): # pylint: disable=too-many-locals if use_kerberos is not None: warn_deprecate('use_kerberos', 'auth_mechanism="GSSAPI"') if use_kerberos: auth_mechanism = 'GSSAPI' if use_ldap is not None: warn_deprecate('use_ldap', 'auth_mechanism="LDAP"') if use_ldap: auth_mechanism = 'LDAP' if auth_mechanism: auth_mechanism = auth_mechanism.upper() else: auth_mechanism = 'NOSASL' if auth_mechanism not in AUTH_MECHANISMS: raise NotSupportedError( 'Unsupported authentication mechanism: {0}'.format(auth_mechanism)) if ldap_user is not None: warn_deprecate('ldap_user', 'user') user = ldap_user if ldap_password is not None: warn_deprecate('ldap_password', 'password') password = ldap_password if protocol is None or protocol.lower() == 'hiveserver2': if protocol: warn_deprecate_protocol() service = hs2.connect(host=host, port=port, timeout=timeout, use_ssl=use_ssl, ca_cert=ca_cert, user=user, password=password, kerberos_service_name=kerberos_service_name, auth_mechanism=auth_mechanism) return hs2.HiveServer2Connection(service, default_db=database) if protocol.lower() == 'beeswax': warn_deprecate_hs2() service = beeswax.connect(host=host, port=port, timeout=timeout, use_ssl=use_ssl, ca_cert=ca_cert, user=user, password=password, kerberos_service_name=kerberos_service_name, auth_mechanism=auth_mechanism) return beeswax.BeeswaxConnection(service, default_db=database) raise NotSupportedError("The specified protocol '%s' is not supported." % protocol)
def connect(host='localhost', port=21050, protocol='hiveserver2', database=None, timeout=45, use_ssl=False, ca_cert=None, use_ldap=False, ldap_user=None, ldap_password=None, use_kerberos=False, kerberos_service_name='impala'): # PEP 249 if protocol.lower() == 'beeswax': warn_deprecate_hs2() service = connect_to_beeswax( host, port, timeout, use_ssl, ca_cert, use_ldap, ldap_user, ldap_password, use_kerberos, kerberos_service_name) return BeeswaxConnection(service, default_db=database) elif protocol.lower() == 'hiveserver2': service = connect_to_hiveserver2( host, port, timeout, use_ssl, ca_cert, use_ldap, ldap_user, ldap_password, use_kerberos, kerberos_service_name) return HiveServer2Connection(service, default_db=database) else: raise NotSupportedError( "The specified protocol '%s' is not supported." % protocol)
def connect(host='localhost', port=21050, protocol=None, database=None, timeout=45, use_ssl=False, ca_cert=None, auth_mechanism='NOSASL', user=None, password=None, kerberos_service_name='impala', use_ldap=None, ldap_user=None, ldap_password=None, use_kerberos=None): if use_kerberos is not None: warn_deprecate('use_kerberos', 'auth_mechanism="GSSAPI"') if use_kerberos: auth_mechanism = 'GSSAPI' if use_ldap is not None: warn_deprecate('use_ldap', 'auth_mechanism="LDAP"') if use_ldap: auth_mechanism = 'LDAP' if auth_mechanism: auth_mechanism = auth_mechanism.upper() else: auth_mechanism = 'NOSASL' if auth_mechanism not in AUTH_MECHANISMS: raise NotSupportedError( 'Unsupported authentication mechanism: {0}'.format(auth_mechanism)) if ldap_user is not None: warn_deprecate('ldap_user', 'user') user = ldap_user if ldap_password is not None: warn_deprecate('ldap_password', 'password') password = ldap_password if protocol is None or protocol.lower() == 'hiveserver2': if protocol: warn_deprecate_protocol() service = hs2.connect(host=host, port=port, timeout=timeout, use_ssl=use_ssl, ca_cert=ca_cert, user=user, password=password, kerberos_service_name=kerberos_service_name, auth_mechanism=auth_mechanism) return hs2.HiveServer2Connection(service, default_db=database) if protocol.lower() == 'beeswax': warn_deprecate_hs2() service = beeswax.connect(host=host, port=port, timeout=timeout, use_ssl=use_ssl, ca_cert=ca_cert, user=user, password=password, kerberos_service_name=kerberos_service_name, auth_mechanism=auth_mechanism) return beeswax.BeeswaxConnection(service, default_db=database) raise NotSupportedError("The specified protocol '%s' is not supported." % protocol)