You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ya...@apache.org on 2022/09/05 05:56:08 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #3395] [DOCS] [Subtask] Add PyHive client docs

This is an automated email from the ASF dual-hosted git repository.

yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new d8e75aa9d [KYUUBI #3395] [DOCS] [Subtask] Add PyHive client docs
d8e75aa9d is described below

commit d8e75aa9dae32ba5acbbbd540a99a7bb08647c41
Author: liangbowen <li...@gf.com.cn>
AuthorDate: Mon Sep 5 13:55:58 2022 +0800

    [KYUUBI #3395] [DOCS] [Subtask] Add PyHive client docs
    
    ### _Why are the changes needed?_
    
    close #3395.
    
    Add client docs for PyHive.
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #3394 from bowenliang123/3309-pyhive-doc.
    
    Closes #3395
    
    31a37b5c [liangbowen] add pyhive docs
    
    Authored-by: liangbowen <li...@gf.com.cn>
    Signed-off-by: Kent Yao <ya...@apache.org>
---
 docs/client/python/pyhive.md  | 68 +++++++++++++++++++++++++++++++++++++++++++
 docs/client/python/pyhive.rst | 22 --------------
 2 files changed, 68 insertions(+), 22 deletions(-)

diff --git a/docs/client/python/pyhive.md b/docs/client/python/pyhive.md
new file mode 100644
index 000000000..f77e3908b
--- /dev/null
+++ b/docs/client/python/pyhive.md
@@ -0,0 +1,68 @@
+<!--
+ - Licensed to the Apache Software Foundation (ASF) under one or more
+ - contributor license agreements.  See the NOTICE file distributed with
+ - this work for additional information regarding copyright ownership.
+ - The ASF licenses this file to You under the Apache License, Version 2.0
+ - (the "License"); you may not use this file except in compliance with
+ - the License.  You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing, software
+ - distributed under the License is distributed on an "AS IS" BASIS,
+ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ - See the License for the specific language governing permissions and
+ - limitations under the License.
+ -->
+
+
+# PyHive
+
+[PyHive](https://github.com/dropbox/PyHive) is a collection of Python DB-API and SQLAlchemy interfaces for Hive. PyHive can connect with the Kyuubi server serving in thrift protocol as HiveServer2.
+
+## Requirements
+PyHive works with Python 2.7 / Python 3. Install PyHive via pip for the Hive interface.
+
+```
+pip install 'pyhive[hive]'
+```
+
+## Usage
+Use the Kyuubi server's host and thrift protocol port to connect.
+
+For further information about usages and features, e.g. DB-API async fetching, using in SQLAlchemy, please refer to [project homepage](https://github.com/dropbox/PyHive).
+
+### DB-API
+
+```python
+from pyhive import hive
+cursor = hive.connect(host=kyuubi_host,port=10009).cursor()
+cursor.execute('SELECT * FROM my_awesome_data LIMIT 10')
+print(cursor.fetchone())
+print(cursor.fetchall())
+```
+
+
+### Use PyHive with Pandas
+PyHive provides a handy way to establish a SQLAlchemy compatible connection and works with Pandas dataframe for executing SQL and reading data via [`pandas.read_sql`](https://pandas.pydata.org/docs/reference/api/pandas.read_sql.html).
+
+```python
+from pyhive import hive
+import pandas as pd
+
+# open connection
+conn = hive.Connection(host=kyuubi_host,port=10009)
+
+# query the table to a new dataframe
+dataframe = pd.read_sql("SELECT id, name FROM test.example_table", conn)
+```
+
+
+### Authentication
+If password is provided for connection, make sure the `auth` param set to either `CUSTOM` or `LDAP`.
+
+```python
+# open connection
+conn = hive.Connection(host=kyuubi_host,port=10009, 
+user='user', password='password', auth='CUSTOM')
+```
\ No newline at end of file
diff --git a/docs/client/python/pyhive.rst b/docs/client/python/pyhive.rst
deleted file mode 100644
index fe2f9cf6d..000000000
--- a/docs/client/python/pyhive.rst
+++ /dev/null
@@ -1,22 +0,0 @@
-.. Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-..    http://www.apache.org/licenses/LICENSE-2.0
-
-.. Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-
-
-`PyHive`_
-=========
-
-.. warning:: The document you are visiting now is incomplete, please help kyuubi community to fix it if appropriate for you.
-
-.. _PyHive: https://github.com/dropbox/PyHive