forked from bellwether/minerva
32 lines
732 B
Python
Executable file
32 lines
732 B
Python
Executable file
#!/usr/bin/env python3
|
|
import minerva
|
|
import pprint
|
|
import readline
|
|
import argparse
|
|
|
|
pp = pprint.PrettyPrinter(indent=4)
|
|
|
|
parser = argparse.ArgumentParser(description="""
|
|
REPL for the Athena SQL engine
|
|
""")
|
|
parser.add_argument("-p", "--profile", default="hay", help="The AWS profile to use")
|
|
parser.add_argument("-o", "--output", default="s3://haystac-pmo-athena/output")
|
|
args = parser.parse_args()
|
|
|
|
m = minerva.Minerva(args.profile)
|
|
athena = m.athena(args.output)
|
|
|
|
text = input("> ")
|
|
while text != "\\q":
|
|
query = athena.query(text)
|
|
|
|
try:
|
|
data = query.results()
|
|
pp.pprint(data.head(10))
|
|
print()
|
|
print(f"\t({'$%.2f' % query.cost}, {query.runtime})")
|
|
except Exception as e:
|
|
print(e)
|
|
|
|
text = input("> ")
|
|
|