I have created a presto cluster using AWS EMR. I am using all of the default configurations. I would like to write a python script on the master node to push queries to presto and get the result.
I found the PyHive library but I don't know what to put into the connect string:
from pyhive import presto # or import hive
cursor = presto.connect('localhost').cursor()
statement = 'SELECT * FROM my_awesome_data LIMIT 10'
cursor.execute(statement)
my_results = cursor.fetchall()
I think that the localhost is probably right because I'm running the script on the master node of the presto cluster, but I'm getting an error:
OperationalError: Unexpected status code 404
b'<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.45 - Error report</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 404 - /v1/statement</h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u>/v1/statement</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><hr class="line"><h3>Apache Tomcat/8.0.45</h3></body></html>'
I figured out that the port that EMR sets up for Presto's web connector is 8889, so with the correct connection:
I get my results: