Skip to content

Instantly share code, notes, and snippets.

@cantoniazzi
Last active September 22, 2020 17:15
Show Gist options
  • Save cantoniazzi/8297ba87156d606fb749e4aada5461cc to your computer and use it in GitHub Desktop.
Save cantoniazzi/8297ba87156d606fb749e4aada5461cc to your computer and use it in GitHub Desktop.
presto connection with python
from pyhive import presto
from pandas import read_sql
def get_presto_conn():
return presto.connect(host='YOUR_PRESTO_HOST', username='YOUR_PRESTO_USERNAME', port='YOUR_PRESTO_PORT')
def get_query_result(presto_conn):
query = 'YOUR_QUERY_HERE'
query_result = read_sql(query, presto_conn)
## your dataframes manipulations here
return query_result
def run():
presto_conn = get_presto_conn()
query_result = get_query_result(presto_conn)
if __name__ == '__main__':
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment