Package: athenacli
IntroductionAthenaCLI is a command line interface (CLI) for theAthenaservice that can do auto-completion and syntax highlighting, and is a proud member of the dbcli community.Quick StartInstallInstall viapipIf you already know how to install python packages, then you can simply do:$pipinstallathenacliInstall viabrewHomebrewusers can install by:$brewinstallathenacliIf you don't know how to install python packages, please check theInstallpage for more options (e.g docker)ConfigA config file is automatically created at~/.athenacli/athenaclircat first launch (run athenacli). See the file itself for a description of all available options.Below 4 variables are required. If you are a user of aws cli, you can refer toawsconfigfile to see how to reuse credentials configuration of aws cli.# AWS credentials
aws_access_key_id = ''
aws_secret_access_key = ''
region = '' # e.g us-west-2, us-east-1

# Amazon S3 staging directory where query results are stored.
# NOTE: S3 should in the same region as specified above.
# The format is 's3://<your s3 directory path>'
s3_staging_dir = ''

# Name of athena workgroup that you want to use
work_group = '' # e.g. primaryor you can also use environment variables:$exportAWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID
$exportAWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
$exportAWS_DEFAULT_REGION=us-west-2
$exportAWS_ATHENA_S3_STAGING_DIR=s3://YOUR_S3_BUCKET/path/to/
$exportAWS_ATHENA_WORK_GROUP=YOUR_ATHENA_WORK_GROUPCreate a table$athenacli-eexamples/create_table.sqlYou can findexamples/create_table.sqlhere.Run a query$athenacli-e'select elb_name, request_ip from elb_logs LIMIT 10'REPL$athenacli[<database_name>]FeaturesAuto-completes as you type for SQL keywords as well as tables and columns in the database.Syntax highlighting.Smart-completion will suggest context-sensitive completion.SELECT * FROM <tab>will only show table names.SELECT * FROM users WHERE <tab>will only show column names.Pretty prints tabular data and various table formats.Some special commands. e.g. Favorite queries.Alias support. Column completions will work even when table names are aliased.Please refer to theFeaturespage for the screenshots of above features.Usages$athenacli--help
Usage:main.py[OPTIONS][DATABASE]AAthenaterminalclientwithauto-completionandsyntaxhighlighting.

Examples:-athenacli-athenaclimy_database

Options:
-e,--executeTEXTExecuteacommand(orafile)andquit.
-r,--regionTEXTAWSregion.
--aws-access-key-idTEXTAWSaccesskeyid.
--aws-secret-access-keyTEXTAWSsecretaccesskey.
--s3-staging-dirTEXTAmazonS3stagingdirectorywherequeryresultsarestored.
--work-groupTEXTAmazonAthenaworkgroupinwhichqueryisrun,defaultisprimary
--athenaclircPATHLocationofathenaclircfile.
--helpShowthismessageandexit.Please go to theUsagesfor detailed information on how to use AthenaCLI.ContributionsIf you're interested in contributing to this project, first of all I would like to extend my heartfelt gratitude. I've written a smalldocto describe how to get this running in a development setup.Please feel free to reach out to me if you need help. My email: zhuzhaolong0 AT gmail comFAQsPlease refer to theFAQsfor other information, e.g. "How can I get support for athenacli?".CreditsA special thanks toAmjith Ramanujamfor creating pgcli and mycli, which inspired me to create this AthenaCLI, and AthenaCLI is created based on a clone of mycli.Thanks toJonathan Slendersfor creating thePython Prompt Toolkit, which leads me to pgcli and mycli. It's a lot of fun playing with this library.Thanks toPyAthenafor a pure python adapter to Athena database.Last but not least, thanks my team and manager encourage me to work on this hobby project.Similar projectssatterly/athena-cli: Presto-like CLI tool for AWS Athena.pengwynn/athena-cli: CLI for Amazon Athena, powered by JRuby.