Skip to main content

Athena CLI

Build Status

Presto-like CLI tool for AWS Athena. The alternative is using the AWS CLI Athena sub-commands.

asciicast

Requirements

A recent version of the aws CLI must be available on the PATH.

Installation

To install using pip run:

$ pip install athena-cli

Or, clone the GitHub repo and run:

$ python setup.py install

Configuration

Only required configuration is AWS credentials.

Usage

$ athena --help
usage: athena [--debug] [--execute <statement>] [--output-format <format>] [--schema <schema>]
              [--profile <profile>] [--region <region>] [--s3-bucket <bucket>]
              [--server-side-encryption] [--version]

Athena interactive console

optional arguments:
  -h, --help            show this help message and exit
  --debug               enable debug mode
  --execute STATEMENT   execute statement in batch mode
  --output-format {ALIGNED,VERTICAL,CSV,TSV,CSV_HEADER,TSV_HEADER,NULL}
                        output format for batch mode
  --schema SCHEMA, --database SCHEMA, --db SCHEMA
                        default schema
  --profile PROFILE     AWS profile
  --region REGION       AWS region
  --s3-bucket BUCKET, --bucket BUCKET
                        AWS S3 bucket for query results
  --server-side-encryption, --encryption
                        Use server-side-encryption for query results
  --version             show version info and exit
athena> help

Supported commands:
QUIT
SELECT
ALTER DATABASE <schema>
ALTER TABLE <table>
CREATE DATABASE <schema>
CREATE TABLE <table>
CREATE TABLE <table> AS <query>
CREATE [OR REPLACE] VIEW <view> AS <query>
DESCRIBE <table>
DROP DATABASE <schema>
DROP TABLE <table>
MSCK REPAIR TABLE <table>
SHOW COLUMNS FROM <table>
SHOW CREATE TABLE <table>
SHOW DATABASES [LIKE <pattern>]
SHOW PARTITIONS <table>
SHOW TABLES [IN <schema>] [<pattern>]
SHOW TBLPROPERTIES <table>
USE [<catalog>.]<schema>
VALUES row [, ...]

See http://docs.aws.amazon.com/athena/latest/ug/language-reference.html

Example

athena> use sampledb;
athena:sampledb> show tables;
 tab_name
------------
 elb_logs
(1 rows)

Query deb156b5-293e-472d-8897-5ee195b06b11, SUCCEEDED
https://eu-west-1.console.aws.amazon.com/athena/home?force&region=eu-west-1#query/history/deb156b5-293e-472d-8897-5ee195b06b11
Time: 0:00:00, CPU Time: 474ms total, Data Scanned: 0.00B, Cost: $0.00

Troubleshooting

Use the --debug option when launching the athena CLI to get AWS debug output:

$ athena --debug
2017-07-21 10:10:45,477 botocore.credentials [DEBUG] Looking for credentials via: env
2017-07-21 10:10:45,478 botocore.credentials [DEBUG] Looking for credentials via: assume-role
2017-07-21 10:10:45,478 botocore.credentials [DEBUG] Looking for credentials via: shared-credentials-file
2017-07-21 10:10:45,479 botocore.credentials [INFO] Found credentials in shared credentials file: ~/.aws/credentials
...

Turn on debug at the athena> prompt by typing:

athena> set debug true
debug - was: False
now: True

Command history is written to ~/.athena_history.

Similar Projects

  • AthenaCLI: CLI tool for AWS Athena service that can do auto-completion and syntax highlighting.
  • athena-cli (Ruby): CLI for Amazon Athena, powered by JRuby.

References

License

Athena CLI
Copyright 2017-2018 Guardian News & Media
Copyright 2019,2023 Nick Satterly

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Metadata

Release files for athena-cli 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for athena-cli 0.1.13
File Size Uploaded
athena-cli-0.1.13.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for athena-cli 0.1.13
File Interpreter ABI Platform
athena_cli-0.1.13-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 24.1 kB

Release files / athena-cli-0.1.13.tar.gz

Download URL athena-cli-0.1.13.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f84a3766aee9ef4df982c251faa640c9961b091724b52e01b2e32fdc31bbdaaf
BLAKE2b-256 checksum
How to use checksums
ada5a3b3a743b32a8479fa96d1c95c2d5bb8d42d8bcb487d530c26f2ce07ba84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / athena_cli-0.1.13-py2.py3-none-any.whl

Download URL athena_cli-0.1.13-py2.py3-none-any.whl
Size 12.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cbcff80ae80faef1e0c649225c8ae7a2326a4e635a254bfb77bb911c2bd20469
BLAKE2b-256 checksum
How to use checksums
b73d3160d3fde379359c77f612c82267c4c425bbe799e439883b2a7cf8c019f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.1.13 This release

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

1 release file

0.1.6

2 release files

0.1.4

1 release file

0.1.1

2 release files

0.1.0

3 release files

0.0.14

1 release file

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

1 release file

0.0.8

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page