In [2]:
from hivejdbc import connect, DictCursor
In [ ]:
 
In [ ]:
 
In [1]:
#!pip install hivejdbc
Collecting hivejdbc
  Downloading https://files.pythonhosted.org/packages/d0/85/84707260fb63ecc7d3e000fc34c103cf2a181644c6adb692a9d76c2d620b/hivejdbc-0.2.3-py3-none-any.whl
Collecting pyjdbc==0.2.2 (from hivejdbc)
  Downloading https://files.pythonhosted.org/packages/f7/ee/2d67440892b53a763003e159440c8d672136cf32aceddd9442e337ca91cc/pyjdbc-0.2.2-py3-none-any.whl
Collecting JPype1>=1.0.1 (from pyjdbc==0.2.2->hivejdbc)
  Downloading https://files.pythonhosted.org/packages/98/88/f817ef1af6f794e8f11313dcd1549de833f4599abcec82746ab5ed086686/JPype1-1.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (448kB)
     |████████████████████████████████| 450kB 19.9MB/s 
Collecting sqlparams>=3.0.0 (from pyjdbc==0.2.2->hivejdbc)
  Downloading https://files.pythonhosted.org/packages/1b/72/e01570409286e92f19280beb0dc3f225198faad3d6efdce3268279977196/sqlparams-3.0.0-py3-none-any.whl
Collecting typing-extensions; python_version < "3.8" (from JPype1>=1.0.1->pyjdbc==0.2.2->hivejdbc)
  Downloading https://files.pythonhosted.org/packages/45/6b/44f7f8f1e110027cf88956b59f2fad776cca7e1704396d043f89effd3a0e/typing_extensions-4.1.1-py3-none-any.whl
Installing collected packages: typing-extensions, JPype1, sqlparams, pyjdbc, hivejdbc
Successfully installed JPype1-1.3.0 hivejdbc-0.2.3 pyjdbc-0.2.2 sqlparams-3.0.0 typing-extensions-4.1.1
In [ ]:
 
In [ ]:
 
In [5]:
conn = connect('hadoop', 
               database='default',
               port=10000,
               driver='hive-client-hive-2.1.1-hdfs-3.0.3-fatjar.jar',
)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-1fb07c504180> in <module>
      2                database='default',
      3                port=10000,
----> 4                driver='hive-client-hive-2.1.1-hdfs-3.0.3-fatjar.jar',
      5 )

/opt/conda/lib/python3.7/site-packages/pyjdbc/connect.py in __call__(self, *args, **kwargs)
    725         :return: Python JdbcConnection instance
    726         """
--> 727         return self.connect(*args, **kwargs)

/opt/conda/lib/python3.7/site-packages/pyjdbc/connect.py in connect(self, *args, **kwargs)
    715         """
    716         arguments = self.parse_args(*args, **kwargs)
--> 717         driver_class = self.load_driver()
    718         return self.get_connection(driver_class, arguments)
    719 

/opt/conda/lib/python3.7/site-packages/pyjdbc/connect.py in load_driver(self)
    636             raise ValueError('"driver_path" is not a valid jar file or directory {}\n'
    637                              '"driver_path" can be set to `None` if the classpath is configured by'
--> 638                              'the user'.format(self.driver_path))
    639 
    640         if self.driver_class is None or not str(self.driver_class).strip():

ValueError: "driver_path" is not a valid jar file or directory /jupyter-folder/tt/hadoop/hive-client-hive-2.1.1-hdfs-3.0.3-fatjar.jar
"driver_path" can be set to `None` if the classpath is configured bythe user
In [ ]:
with conn.cursor() as cursor:
    cursor.execute('select * from test.persons')
    rows = cursor.fetchall()
In [6]:
!find / -name "*fatjar.jar"
find: '/proc/7/task/7/net': Invalid argument
find: '/proc/7/net': Invalid argument
find: '/proc/147/task/147/net': Invalid argument
find: '/proc/147/net': Invalid argument
find: '/proc/194/task/194/net': Invalid argument
find: '/proc/194/net': Invalid argument
In [ ]: