Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Big Data Hadoop & Spark by (108k points)

I have installed HDP 2.5 Sandbox on my windows system. I want to access Hive running on Sandbox using Python (to be specific "pyhive" library). 

I can log in to the HDP. The IP address is 127.0.0.1. I have installed a pyhive library. However, I am unable to connect from the system to Sandbox from python. 

Can you suggest what to do?

1 Answer

0 votes
by (50.2k points)

The following code represents how we can connect to Hive using pyhive:

from pyhive import hive

import pandas as pd

#Create Hive connection 

conn = hive.Connection(host="127.0.0.1", port=10000, username="username")

# Read Hive table and Create pandas dataframe

df = pd.read_sql("SELECT * FROM db_Name.table_Name limit 10", conn)

print(df.head())

Related questions

Browse Categories

...