From d4ae481675ac5588ba9101596fa26f22ef0e77c4 Mon Sep 17 00:00:00 2001 From: Multazim Deshmukh <57723564+mdeshmu@users.noreply.github.com> Date: Wed, 12 Jul 2023 16:09:00 +0530 Subject: [PATCH] update readme to reflect recent changes (#459) --- README.rst | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 5afd746c..bb10e607 100644 --- a/README.rst +++ b/README.rst @@ -14,8 +14,8 @@ PyHive ====== PyHive is a collection of Python `DB-API `_ and -`SQLAlchemy `_ interfaces for `Presto `_ and -`Hive `_. +`SQLAlchemy `_ interfaces for `Presto `_ , +`Hive `_ and `Trino `_. Usage ===== @@ -25,7 +25,7 @@ DB-API .. code-block:: python from pyhive import presto # or import hive or import trino - cursor = presto.connect('localhost').cursor() + cursor = presto.connect('localhost').cursor() # or use hive.connect or use trino.connect cursor.execute('SELECT * FROM my_awesome_data LIMIT 10') print cursor.fetchone() print cursor.fetchall() @@ -61,7 +61,7 @@ In Python 3.7 `async` became a keyword; you can use `async_` instead: SQLAlchemy ---------- -First install this package to register it with SQLAlchemy (see ``setup.py``). +First install this package to register it with SQLAlchemy, see ``entry_points`` in ``setup.py``. .. code-block:: python @@ -117,7 +117,7 @@ Passing session configuration 'session_props': {'query_max_run_time': '1234m'}} ) create_engine( - 'trino://user@host:443/hive', + 'trino+pyhive://user@host:443/hive', connect_args={'protocol': 'https', 'session_props': {'query_max_run_time': '1234m'}} ) @@ -136,15 +136,18 @@ Requirements Install using -- ``pip install 'pyhive[hive]'`` for the Hive interface and -- ``pip install 'pyhive[presto]'`` for the Presto interface. +- ``pip install 'pyhive[hive]'`` or ``pip install 'pyhive[hive_pure_sasl]'`` for the Hive interface +- ``pip install 'pyhive[presto]'`` for the Presto interface - ``pip install 'pyhive[trino]'`` for the Trino interface +Note: ``'pyhive[hive]'`` extras uses `sasl `_ that doesn't support Python 3.11, See `github issue `_. +Hence PyHive also supports `pure-sasl `_ via additional extras ``'pyhive[hive_pure_sasl]'`` which support Python 3.11. + PyHive works with - Python 2.7 / Python 3 -- For Presto: Presto install -- For Trino: Trino install +- For Presto: `Presto installation `_ +- For Trino: `Trino installation `_ - For Hive: `HiveServer2 `_ daemon Changelog @@ -162,6 +165,26 @@ Contributing - 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. +Tips for test environment setup +================================ +You can setup test environment by following ``.travis.yaml`` in this repository. It uses `Cloudera's CDH 5 `_ which requires username and password for download. +It may not be feasible for everyone to get those credentials. Hence below are alternative instructions to setup test environment. + +You can clone `this repository `_ which has Docker Compose setup for Presto and Hive. +You can add below lines to its docker-compose.yaml to start Trino in same environment:: + + trino: + image: trinodb/trino:351 + ports: + - "18080:18080" + volumes: + - ./trino:/etc/trino + +Note: ``./trino`` for docker volume defined above is `trino config from PyHive repository `_ + +Then run:: + docker-compose up -d + Testing ======= .. image:: https://travis-ci.org/dropbox/PyHive.svg