Skip to content

Instantly share code, notes, and snippets.

@tommarute
Created February 6, 2018 12:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tommarute/9e6c18350964d99988667707b66af259 to your computer and use it in GitHub Desktop.
Save tommarute/9e6c18350964d99988667707b66af259 to your computer and use it in GitHub Desktop.
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