Created
February 6, 2018 12:58
-
-
Save tommarute/9e6c18350964d99988667707b66af259 to your computer and use it in GitHub Desktop.
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 | |
import requests | |
from requests.auth import HTTPBasicAuth | |
import pandas as pd | |
requests.packages.urllib3.disable_warnings() | |
req_kw = { | |
'auth': HTTPBasicAuth('the-user', 'the-password'), | |
'verify': '/path/to/cert.pem', | |
} | |
conn = presto.connect( | |
host='your-presto-host.net', | |
port=8080, | |
protocol='https', | |
catalog='the-catalog', | |
schema='the-schema', | |
username='the-user', | |
requests_kwargs=req_kw, | |
) | |
query = """ | |
select | |
user_id as id, | |
user_name as name | |
from | |
users | |
where | |
user_id <= 100""" | |
col = ['id', 'name'] | |
cursor = conn.cursor() | |
cursor.execute(query) | |
df = pd.DataFrame(cursor.fetchall(), columns=col) | |
print(df) | |
cursor.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment