forked from bellwether/minerva
added binary file for an easy athena console
This commit is contained in:
parent
383185e6cb
commit
ab344374d9
3 changed files with 50 additions and 3 deletions
32
bin/minerva-console
Executable file
32
bin/minerva-console
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/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("> ")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue