Created
February 24, 2020 15:53
-
-
Save ottomata/a0d2ba4ad104f4d87b3b00ff9292b840 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !pip install git+https://github.com/dropbox/PyHive.git@437eefa7bceda1fd27051e5146e66cb8e4bdfea1 | |
# !pip install requests-kerberos | |
import os | |
import socket | |
from pyhive import presto | |
def get_presto_cursor( | |
host="an-coord1001.eqiad.wmnet", | |
port=8281, | |
catalog='analytics_hive', | |
protocol='https', | |
source='Presto Jupyter - {}@{}'.format(os.geteuid, socket.gethostname()), | |
ca_crt='/etc/presto/ca.crt.pem', | |
KerberosConfigPath="/etc/krb5.conf", | |
KerberosPrincipal="{}@WIKIMEDIA".format(os.getenv('USER')), | |
KerberosRemoteServiceName="presto", | |
KerberosCredentialCachePath='/tmp/krb5cc_{}'.format(os.geteuid()) | |
): | |
requests_kwargs = { | |
proxies: { | |
'http': None, 'https': None | |
} | |
} | |
if ca_crt: | |
requests_kwargs['verify'] = ca_crt | |
presto_cursor = presto.Cursor( | |
host=host, | |
port=port, | |
catalog=catalog, | |
protocol=protocol, | |
requests_kwargs=requests_kwargs, | |
KerberosConfigPath=KerberosConfigPath, | |
KerberosPrincipal=KerberosPrincipal, | |
KerberosRemoteServiceName=KerberosRemoteServiceName, | |
KerberosCredentialCachePath=KerberosCredentialCachePath | |
) | |
return presto_cursor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment