Last active
September 22, 2020 17:15
-
-
Save cantoniazzi/8297ba87156d606fb749e4aada5461cc to your computer and use it in GitHub Desktop.
presto connection with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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