SqlAlchemy connection to Hive using http thrift transport and basic auth

42 Views Asked by At

i'm facing issue trying to create a SQLAlchemy engine to connect to my hive db.

Using pyHive i managed to connect using thrift_transport using this script:

def thrift_http_transport():
    transport = thrift.transport.THttpClient.THttpClient(uri_or_host='https://<host>:<port>/cliservice')

    auth_credentials = '{}:{}'.format('<user>', '<pass>').encode('UTF-8')
    auth_credentials_base64 = base64.standard_b64encode(auth_credentials).decode('UTF-8')
    transport.setCustomHeaders(
        {
            'Authorization': 'Basic {}'.format(auth_credentials_base64),  # HiveServer2 BASIC auth
        }
    )
    return transport



conn = hive.connect(thrift_transport=thrift_http_transport())

Now, i've tried to create a SQLAlchemy engine as it follows:

engine = sqlalchemy.create_engine("hive://user:pass@host:port/default;auth=CUSTOM") or engine = sqlalchemy.create_engine("hive+https://user:pass@host:port")

with no result. I'm new to the hive technology and trying to learn right now. hope that the infos are enough.

Thanks a lot in advance

**Update, adding error stacktrace:

thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
0

There are 0 best solutions below