john-bodley / PyHive

Python interface to Hive and Presto. 🐝

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image

PyHive

PyHive is a collection of Python DB-API and SQLAlchemy interfaces for Presto and Hive.

Usage

DB-API

DB-API (asynchronous)

SQLAlchemy

First install this package to register it with SQLAlchemy (see setup.py).

Note: query generation functionality is not exhaustive or fully tested, but there should be no problem with raw SQL.

Passing session configuration

Requirements

Install using

  • pip install pyhive[hive] for the Hive interface and
  • pip install pyhive[presto] for the Presto interface.

PyHive works with

  • Python 2.7 / Python 3
  • For Presto: Presto install
  • For Hive: HiveServer2 daemon
  • For Python 3 + Hive + SASL, you currently need to install an unreleased version of thrift_sasl (pip install git+https://github.com/cloudera/thrift_sasl). At the time of writing, the latest version of thrift_sasl was 0.2.1.

Changelog

See https://github.com/dropbox/PyHive/releases.

Contributing

  • Please fill out the Dropbox Contributor License Agreement at https://opensource.dropbox.com/cla/ and note this in your pull request.
  • Changes must come with tests, with the exception of trivial things like fixing comments. See .travis.yml for the test environment setup.
  • Notes on project scope:
    • This project is intended to be a minimal Hive/Presto client that does that one thing and nothing else. Features that can be implemented on top of PyHive, such integration with your favorite data analysis library, are likely out of scope.
    • We prefer having a small number of generic features over a large number of specialized, inflexible features. For example, the Presto code takes an arbitrary requests_session argument for customizing HTTP calls, as opposed to having a separate parameter/branch for each requests option.

Testing

image

image

Run the following in an environment with Hive/Presto:

./scripts/make_test_tables.sh
virtualenv --no-site-packages env
source env/bin/activate
pip install -e .
pip install -r dev_requirements.txt
py.test

WARNING: This drops/creates tables named one_row, one_row_complex, and many_rows, plus a database called pyhive_test_database.

About

Python interface to Hive and Presto. 🐝

License:Other


Languages

Language:Python 94.6%Language:Shell 5.0%Language:Java 0.4%