Skip to content

Instantly share code, notes, and snippets.

@gulrich1
Created March 20, 2020 18:03
Show Gist options
  • Save gulrich1/60b7dabcfa11da8d01fb5e867eae9c1e to your computer and use it in GitHub Desktop.
Save gulrich1/60b7dabcfa11da8d01fb5e867eae9c1e to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import prestodb
import getpass
def build_presto_connector(user, password):
conn=prestodb.dbapi.connect(
host='datalake.despegar.com',
port=443,
user=user,
catalog='data.lake',
schema='clm_transactions',
http_scheme='https',
auth=prestodb.auth.BasicAuthentication(user, password),
)
return conn.cursor()
def get_rows_from_query(query):
cur.execute(query)
results = cur.fetchall()
return results
query = ("select ext_despegar_trn_id as id, transaction_date " +
"from data.lake.clm_transactions " +
" where ext_despegar_trn_id is not null " +
" limit 10")
user = input("User ([email protected]): ")
password = getpass.getpass('Enter your password')
cur = build_presto_connector(user, password)
rows = get_rows_from_query(query)
for row in rows:
# print id
print(row[0])
print("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment