New Contributor
Posts: 2
Registered: ‎07-11-2018

Using python to connect to Hive in cloudera

please i need help , i write this simple code in python but i have problem with packages 


from pyhive import hive
import pandas as pd

#Create Hive connection
conn = hive.Connection(host="", port=10000, username="cloudera" , database="default")

# Read Hive table and Create pandas dataframe
df = pd.read_sql("SELECT * FROM etudiantsv ", conn)

sur anaconda avec python 2 : erreur 
in __init__(self, host, port, username, database, auth, configuration, kerberos_service_name, password, thrift_transport)
150 elif auth in ('LDAP', 'KERBEROS', 'NONE', 'CUSTOM'):
151 # Defer import so package dependency is optional
--> 152 import sasl
153 import thrift_sasl

ImportError: No module named sasl

in  pycharm python 3.7

i have this error : 

def execute(self, operation, parameters=None, async=False):
SyntaxError: invalid syntax

Expert Contributor
Posts: 127
Registered: ‎01-08-2018

Re: Using python to connect to Hive in cloudera

Regarding python 2. If your hive server is configured with SSL, then you should consider installing "sasl" package in python.


As about python3, although this is a python question not hive related, usually the issue is on the previous lines, e.g. quotes or parentheses that do not terminate.