Skip to main content

hivejdbc

hivejdbc is db-api-2.0 compliant Apache Hive driver that supports

  • kerberos
  • ssl
  • service discovery via zookeeper
  • host-connection list
  • and all other jdbc driver options

installation

pip3 install hivejdbc

Cursors

hivejdbc can use a dictonary cursor if desired.

from hivejdbc import connect, DictCursor
conn = connect('example.com', 'default', cursor=DictCursor)

Connection Strings

hivejdbc features many connect function arguments. Many of these arguments can be ignored and are simply present to offer the full options provided by the Hive jdbc driver.

To import the hivejdbc connect function:

from hivejdbc import connect

Unsecured Hive Instance

to connect to an unsecured hive instance listening on the default port 10000, and the default database:

conn = connect('example.com', 'default')

unless all required hive-jars are on the classpath already you'll need to define the driver path
Java uses jar files to combine many libraries into one. We'll use our fatjar to provide all the required dependencies in one place.
Make sure you're using the correct driver for your Hive version.

conn = connect('example.com', 'default', driver='hive-client-hive-2.1.1-hdfs-3.0.3-fatjar.jar')

to connect with a custom port of 10015

conn = connect('example.com', 'default', port=10015)

Username and Password

conn = connect(host='example.com', 
               database='default', 
               port=10015, 
               user='hive_user', 
               password='secret')

SSL

If the hive-server has ssl enabled you'll need to provide a jks trust store that contains the servers public certificate.

conn = connect(host='hive2.example.com',
               port=10015,
               database='default',
               driver='hive-client-hive-2.1.1-hdfs-3.0.3-fatjar.jar',
               ssl=True,
               trust_store='./truststore.jks',
               trust_password='changeit',
               principal='hive/hive2.example.com@EXAMPLE.COM',
               user_principal='hive/hive2.example.com',
               user_keytab='hive.keytab',
               realm='EXAMPLE.COM',
               kdc='kerberosdc.example.com:88')

Kerberos

Authenticating with kerberos can be done a few ways:

  1. get valid kerberos credentials via kinit before running hivejdbc
  2. rely on hivejdbc to obtain kerberos credentials via a user-principal and user-keytab provided to the program.

Operating System kinit

Connect to...

  • a ssl enabled cluster
  • a secured cluster (kerberos)
  • using the operating systems kerberos configuration default locations are searched depending on platform
  • using the operating system kinit token
    default locations for the token-cache are searched
  • if kinit has not been performed, or a token-cache cannot be found an exception will be thrown
conn = connect(host='hive2.example.com',
               port=10015,
               database='default',
               driver='hive-client-hive-2.1.1-hdfs-3.0.3-fatjar.jar',
               ssl=True,
               trust_store='./truststore.jks',
               trust_password='changeit',
               principal='hive/hive2.example.com@EXAMPLE.COM')

hivejdbc does the kinit via keytab and a custom krb5.conf

connect to...

  • a ssl enabled cluster
  • a secured cluster (kerberos)
  • using the operating systems kerberos configuration krb5.conf
  • using a keytab for authentication
    the keytab will be used to login via java's built-in kerberos implementation avoiding the need for any operating system dependency
  • we will provide the kdc and realm via the krb5_conf argument if we didn't provide krb5_conf argument default locations would be searched within various system paths
conn = connect(host='hive2.example.com',
               port=10015,
               database='default',
               driver='hive-client-hive-2.1.1-hdfs-3.0.3-fatjar.jar',
               ssl=True,
               trust_store='./truststore.jks',
               trust_password='changeit',
               principal='hive/hive2.example.com@EXAMPLE.COM',
               krb5_conf='kerberos/custom_krb5.conf',
               user_principal='hive/hive2.example.com',
               user_keytab='a133041.keytab')

hivejdbc does the kinit via keytab with no krb5.conf

connect to...

  • an ssl enabled cluster
  • a secured cluster (kerberos)
  • not using the operating system or relying on any of its configurations
  • manually setting the realm, and the kerberos "kdc" to authenticate to
  • using a keytab for authentication
  • this configuration is the most portable...
conn = connect(host='hive2.example.com',
               port=10015,
               database='default',
               driver='hive-client-hive-2.1.1-hdfs-3.0.3-fatjar.jar',
               ssl=True,
               trust_store='./truststore.jks',
               trust_password='changeit',
               principal='hive/hive2.example.com@EXAMPLE.COM',
               user_principal='hive/hive2.example.com',
 ~~~~              user_keytab='hive.keytab',
               realm='EXAMPLE.COM',
               kdc='kerberosdc.example.com:88')

Metadata

Release files for hivejdbc 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hivejdbc 0.1.3
File Size Uploaded Provenance Actions
hivejdbc-0.1.3.tar.gz 13.1 kB Without provenance Details for hivejdbc-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hivejdbc 0.1.3
File Interpreter ABI Platform Actions
hivejdbc-0.1.3-py3-none-any.whl Python 3 none any Details for hivejdbc-0.1.3-py3-none-any.whl

Total release size: 25.3 kB

Release files / hivejdbc-0.1.3.tar.gz

Download URL hivejdbc-0.1.3.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
de1a63236ebcafc33300b5ca57bf2b0afb5786718a87feb6a9203f01b26a0fd0
BLAKE2b-256 checksum
How to use checksums
d096bf532aad027fbe75ad07722b247399c33c030b3954d050e49cf3b7cd1d4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / hivejdbc-0.1.3-py3-none-any.whl

Download URL hivejdbc-0.1.3-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a1416e915265e80a92a8c5a3d39f8bc51986a54593a12faeddba79b36bf65c8
BLAKE2b-256 checksum
How to use checksums
9b8c2bece9fcd1b4b236b0a491bdcf89a2113a3820c44e7bf0775806592ec659
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Security for hivejdbc 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page