-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
31 lines (24 loc) · 878 Bytes
/
test.py
File metadata and controls
31 lines (24 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pyhive import hive
import pandas as pd
import matplotlib.pyplot as plt
# Connect to Hive via SSH tunnel
# conn = hive.Connection(host='localhost', port=11001, auth='NOSASL')
#
# conn = hive.Connection(host='https://hd-iot-twitter-cluster-1.azurehdinsight.net', port=10001, username='sshuser')
host_name = "10.3.141.44"
port = 10000
database="ncc"
def hiveconnection(host_name, port, database):
conn = hive.Connection(host=host_name, port=port,
database=database, auth='NOSASL')
cur = conn.cursor()
cur.execute('select * from registry')
result = cur.fetchall()
return result
output = hiveconnection(host_name, port, database)
print(output)
# cursor = conn.cursor()
# cursor.execute("SELECT sentiment, COUNT(*) FROM twitter_sentiments GROUP BY sentiment")
# for row in cursor.fetchall():
# print(row)
# Run Hive query