Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A package interact with Hive Server 2 via the Thrift protocol

Project description

This project aims to be an up to date Python client to interact with Hive Server 2 using the Thrift protocol.

The project is heavily inspired by PyHive up to the point that part of the code has been snatched from there. See Differences for more.

Installation

Install it with pip install hs2client or directly from source

python setup.py install

Usage

Using it from Python is simple:

from hs2client.hs2client import HS2Client

client = HS2Client(host='127.0.0.1', username='user', port=10000, auth='NONE')

with client as connection, connection.cursor() as cursor:
    cursor.arraysize = 10
    cursor.execute('select * from table')
    for row in cursor:
        print(row)

Regenerate the Python thrift library

The hs2client.py is just a thin wrapper around the generated Python code to interact with Hive Server 2 through the Thrift protocol.

To regenerate the code using a newer version of the .thrift files, you can use generate.py (note: you need to have thrift installed, see here)

python generate.py --help

Usage: generate.py [OPTIONS]

Options:
  --hive_server2_url TEXT The URL where the TCLIService.thrift file can be downloaded
  --package TEXT          The package where the client should be placed
  --subpackage TEXT       The subpackage where the client should be placed
  --help                  Show this message and exit.

Otherwise the defaults will be used.

Differences with PyHive

  • This pakcage lacks the sqlalchemy and the presto part;
  • The main class, HS2Client inherits from TCLIService.Client, making certain things handier;
  • In cases where authentication is NONE, the username is set to mr.who to avoid issues with the latest Hive Server 2 versions;
  • Thrift 0.11 has been used to generate the Python files;
  • The generate.py file allows to easily update the files generated from the thrift specs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for hs2client, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size hs2client-0.1.1-py2.7.egg (80.3 kB) File type Egg Python version 2.7 Upload date Hashes View hashes
Filename, size hs2client-0.1.1-py3.6.egg (84.3 kB) File type Egg Python version 3.6 Upload date Hashes View hashes
Filename, size hs2client-0.1.1-py3-none-any.whl (32.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size hs2client-0.1.1.tar.gz (30.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page