{"id":20449594,"url":"https://github.com/skatsuta/athenai","last_synced_at":"2025-10-14T08:39:41.918Z","repository":{"id":81565297,"uuid":"92182250","full_name":"skatsuta/athenai","owner":"skatsuta","description":"Have fun with Amazon Athena from command line! 🕊","archived":false,"fork":false,"pushed_at":"2017-11-20T15:00:01.000Z","size":14292,"stargazers_count":36,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-14T08:39:38.768Z","etag":null,"topics":["athena","aws","cli","command-line-tool","go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skatsuta.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-23T14:26:01.000Z","updated_at":"2023-01-20T00:33:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae9a3f40-0750-4e8e-8a6c-8bbf01a31418","html_url":"https://github.com/skatsuta/athenai","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/skatsuta/athenai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skatsuta%2Fathenai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skatsuta%2Fathenai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skatsuta%2Fathenai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skatsuta%2Fathenai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skatsuta","download_url":"https://codeload.github.com/skatsuta/athenai/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skatsuta%2Fathenai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018301,"owners_count":26086345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["athena","aws","cli","command-line-tool","go"],"created_at":"2024-11-15T10:42:44.942Z","updated_at":"2025-10-14T08:39:41.890Z","avatar_url":"https://github.com/skatsuta.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"docs/logo.jpg\" alt=\"logo\"\u003e\u003c/p\u003e\n\n\n# Athenai\n\n[![wercker status](https://app.wercker.com/status/554177081896c1c508e365ffa1c8cc26/s/master \"wercker status\")](https://app.wercker.com/project/byKey/554177081896c1c508e365ffa1c8cc26)\n[![codecov](https://codecov.io/gh/skatsuta/athenai/branch/master/graph/badge.svg?token=dkRnWrYYa9)](https://codecov.io/gh/skatsuta/athenai)\n[![Go Report Card](https://goreportcard.com/badge/github.com/skatsuta/athenai)](https://goreportcard.com/report/github.com/skatsuta/athenai)\n[![Readme Score](http://readme-score-api.herokuapp.com/score.svg?url=skatsuta/athenai)](http://clayallsopp.github.io/readme-score?url=skatsuta/athenai)\n\nHave fun with Amazon Athena from command line! 🕊\n\n\n## Overview\n\nAthenai is a simple and easy-to-use command line tool that runs SQL statements on [Amazon Athena](https://aws.amazon.com/athena/).\n\nWith Athenai you can run multiple queries easily at a time on Amazon Athena and can see the results in table or CSV format interactively once the executions have finished.\n\n\"A picture is worth a thousand words.\" See the **[Demo](#demo)** section to see how it works 👀\n\n\n## Demo\n\n![Demo](docs/demo.gif)\n\n\n## Features\n\n- **Easy to use**: provide queries, wait for query executions and see the results once the executions have finished.\n- **Various input methods**: REPL, command line arguments or SQL file.\n- **Concurrent executions**: run multiple queries concurrently at a time.\n- **Query cancellation**: cancel queries if `Ctrl-C` is pressed during the executions.\n\n\n## Installation\n\nAthenai is currently supported on macOS and Linux.\n\n### Installing from binary\n\n[Download the archive](https://github.com/skatsuta/athenai/releases/latest), extract it and place the executable somewhere in `PATH`.\nFor example,\n\n```bash\n# Please replace ${VERSION}, ${OS} and ${ARCH} with appropriate values for your platform.\n$ curl -sL https://github.com/skatsuta/athenai/releases/download/${VERSION}/athenai_${OS}_${ARCH}.tar.gz -o athenai.tar.gz\n$ tar -xzf athenai.tar.gz\n$ mv athenai /usr/local/bin/ # or wherever you like in PATH\n$ athenai --help\n```\n\n### Installing via Homebrew (macOS only)\n\nAthenai provides [a repository for Homebrew](https://github.com/skatsuta/homebrew-athenai). If you use [Homebrew](https://brew.sh/), you can install the binary as follows:\n\n```bash\n$ brew install skatsuta/athenai/athenai\n$ athenai --help\n```\n\n### Installing from source\n\nIf you use Go, you can build and install your binary from source using `go get`:\n\n```bash\n$ go get -v github.com/skatsuta/athenai\n# ...\n$ $GOPATH/bin/athenai --help\n```\n\n\n## Setup\n\n### AWS creadentitals (Required)\n\nBefore using this tool, you need to set up AWS credentials just like using AWS CLI or AWS SDK.\nIf you already use them and have sufficient IAM permissions to use Amazon Athena, you may not need this step 😊\nIn that case just skip to the next **[Default configuration file](#default-configuration-file-optional-)** section! 🚀\n\nTo set up AWS credentials, there are mainly three ways:\n\n* [Configuring environment variables](http://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html): simple, but not recommended.\n* [Configuring shared credentials file (`$HOME/.aws/credentials`)](http://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html): recommended for use on local computers.\n* [Configuring instance profile](http://docs.aws.amazon.com/cli/latest/userguide/cli-metadata.html): recommended for use on EC2 instances.\n\nPlease follow one of the above instructions corresponding to your use case.\n\nAfter setting it up, make sure your IAM user or role to use has correct Amazon Athena and Amazon S3 permissions.\n**To use Athenai, [AmazonAthenaFullAccess Managed Policy](http://docs.aws.amazon.com/athena/latest/ug/access.html#amazonathenafullaccess-managed-policy-contents) has to be attached to your IAM user or role to use.**\n\n### Default configuration file (Optional; Recommended)\n\nYou can optionally set your default configuration values into your `$HOME/.athenai/config` file to simplify every command execution.\n\nWrite the following into `$HOME/.athenai/config` and save it.\u003cbr\u003e\n(Modify the `profile` value if you use another profile in your `$HOME/.aws/credentials`, instead of `default`.)\n\n```ini\n[default]\n# (Optional) Profile in your $HOME/.aws/credentials file\nprofile = default\n# AWS region\nregion = us-east-1\n# Database name\ndatabase = sampledb\n# Output location in S3 where query results will be stored\nlocation = s3://aws-athena-query-results-\u003cYOUR_ACCOUNT_ID\u003e-us-east-1/\n```\n\nThen Athenai loads the configuration file automatically and you can omit the option flags when running commands.\n\nSee the **[Configuration file](#configuration-file)** section for more details.\n\n\n## Usage\n\n#### Note: option flags\n\nIn this section, it is assumed that you have already set up [the default configuration file](#default-configuration-file-optional-recommended), and option flags are omitted to describe the main usage as simply as possible.\nIf you haven't done it yet or want to override the default values in your config file, run a command with flags like this:\n\n```\n$ athenai run \\\n  --profile default \\\n  --region us-east-1 \\\n  --database sampledb \\\n  --location s3://aws-athena-query-results-\u003cYOUR_ACCOUNT_ID\u003e-us-east-1/ \\\n  \"SELECT date, time, bytes, requestip, method, status FROM cloudfront_logs LIMIT 5;\"\n```\n\n(Modify the `--profile` flag if you use another profile in your `$HOME/.aws/credentials`, instead of `default`.)\n\n### Running queries interactively (REPL mode)\n\n![Running queries interactively](docs/run_repl.gif)\n\nTo run queries on interactive (REPL) mode, run `athenai run` command with no arguments except for flags:\n\n```\n$ athenai run\nathenai\u003e SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n⠚ Running query...\nQuery: SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n+------------+----------+-------+-----------+--------+--------+\n| date       | time     | bytes | requestip | method | status |\n| 2014-07-05 | 15:00:00 |  4260 | 10.0.0.15 | GET    |    200 |\n| 2014-07-05 | 15:00:00 |    10 | 10.0.0.15 | GET    |    304 |\n| 2014-07-05 | 15:00:00 |  4252 | 10.0.0.15 | GET    |    200 |\n| 2014-07-05 | 15:00:00 |  4257 | 10.0.0.8  | GET    |    200 |\n| 2014-07-05 | 15:00:03 |  4261 | 10.0.0.15 | GET    |    200 |\n+------------+----------+-------+-----------+--------+--------+\nRun time: 3.12 seconds | Data scanned: 101.27 KB\nLocation: s3://aws-athenai-demo/835573f3-8ff9-4fd3-a1a4-097f4921b93d.csv\nathenai\u003e SHOW DATABASES; SHOW TABLES;\n⠴ Running query...\nQuery: SHOW DATABASES;\n+-----------------+\n| cloud_trail     |\n| cloudfront_logs |\n| default         |\n| elb_logs        |\n| s3_logs         |\n| sampledb        |\n+-----------------+\nRun time: 0.32 seconds | Data scanned: 0 B\nLocation: s3://aws-athenai-demo/ba7de01a-8159-4a66-8453-d68294d9871d.txt\n\nQuery: SHOW TABLES;\n+-----------------+\n| cloudfront_logs |\n| elb_logs        |\n| flights_parquet |\n+-----------------+\nRun time: 0.40 seconds | Data scanned: 0 B\nLocation: s3://aws-athenai-demo/150a8494-0750-43ad-8971-9dd68c75f076.txt\nathenai\u003e ^D\n$ \n```\n\nIn REPL mode you can use common key shortcuts just like on most shells. For example,\n\nKey | Action\n:---:|---\n`↑`/`Ctrl-P` | Move to the previous line in history\n`↓`/`Ctrl-N` | Move to the next line in history\n`Ctrl-A` | Move cursor to the beginning of the line\n`Ctrl-E` | Move cursor to the end of the line\n`Ctrl-H` | Delete a character\n\nand so on.\nAvailable shortcuts are listed [here](https://github.com/chzyer/readline/blob/master/doc/shortcut.md).\n\nYour query history is saved to the `$HOME/.athenai/history` file automatically.\n\nTo exit REPL, press `Ctrl-C` or `Ctrl-D` on empty line.\n\n### Running queries from command line arguments\n\n![Running queries from command line arguments](docs/run_arg.gif)\n\nTo run queries from command line arguments, just pass them to `athenai run` command:\n\n```\n$ athenai run \"SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\"\n⠙ Running query...\nQuery: SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n+------------+----------+-------+-----------+--------+--------+\n| date       | time     | bytes | requestip | method | status |\n| 2014-07-05 | 15:00:00 |  4260 | 10.0.0.15 | GET    |    200 |\n| 2014-07-05 | 15:00:00 |    10 | 10.0.0.15 | GET    |    304 |\n| 2014-07-05 | 15:00:00 |  4252 | 10.0.0.15 | GET    |    200 |\n| 2014-07-05 | 15:00:00 |  4257 | 10.0.0.8  | GET    |    200 |\n| 2014-07-05 | 15:00:03 |  4261 | 10.0.0.15 | GET    |    200 |\n+------------+----------+-------+-----------+--------+--------+\nRun time: 2.35 seconds | Data scanned: 101.27 KB\nLocation: s3://aws-athenai-demo/71940569-f9ce-41d7-81c0-587ff0aeffda.csv\n\n$ athenai run \"SHOW DATABASES; SHOW TABLES;\"\n⠦ Running query...\nQuery: SHOW DATABASES;\n+-----------------+\n| cloud_trail     |\n| cloudfront_logs |\n| default         |\n| elb_logs        |\n| s3_logs         |\n| sampledb        |\n+-----------------+\nRun time: 0.38 seconds | Data scanned: 0 B\nLocation: s3://aws-athenai-demo/c572a884-1cba-472d-a568-ac8e1e75551b.txt\n\nQuery: SHOW TABLES;\n+-----------------+\n| cloudfront_logs |\n| elb_logs        |\n| flights_parquet |\n+-----------------+\nRun time: 0.41 seconds | Data scanned: 0 B\nLocation: s3://aws-athenai-demo/e70c473c-9994-4247-991c-8d739a7249cc.txt\n```\n\n### Running queries from SQL file\n\n![Running queries from an SQL file](docs/run_file.gif)\n\nTo run queries from an SQL file, pass its path with `file://` prefix to `athenai run` command:\n\n```\n$ cat sample.sql\nSELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n$ athenai run file://sample.sql\n⠚ Running query...\nQuery: SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n+------------+----------+-------+-----------+--------+--------+\n| date       | time     | bytes | requestip | method | status |\n| 2014-08-05 | 15:56:57 |  4252 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:58 |  4257 | 10.0.0.3  | GET    |    200 |\n| 2014-08-05 | 15:56:58 |  4252 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:58 |  4251 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:59 |    10 | 10.0.0.15 | GET    |    304 |\n+------------+----------+-------+-----------+--------+--------+\nRun time: 2.03 seconds | Data scanned: 101.82 KB\nLocation: s3://aws-athenai-demo/836b5b3f-5fdd-447f-9b02-dc869bc8d03d.csv\n```\n\nor pass its contents via stdin:\n\n```\n$ cat sample.sql\nSELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n$ athenai run \u003c sample.sql\n⠲ Running query...\nQuery: SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n+------------+----------+-------+-----------+--------+--------+\n| date       | time     | bytes | requestip | method | status |\n| 2014-07-05 | 15:00:00 |  4260 | 10.0.0.15 | GET    |    200 |\n| 2014-07-05 | 15:00:00 |    10 | 10.0.0.15 | GET    |    304 |\n| 2014-07-05 | 15:00:00 |  4252 | 10.0.0.15 | GET    |    200 |\n| 2014-07-05 | 15:00:00 |  4257 | 10.0.0.8  | GET    |    200 |\n| 2014-07-05 | 15:00:03 |  4261 | 10.0.0.15 | GET    |    200 |\n+------------+----------+-------+-----------+--------+--------+\nRun time: 1.99 seconds | Data scanned: 101.27 KB\nLocation: s3://aws-athenai-demo/686f3498-cb31-4731-84ed-5dce9614c6c3.csv\n```\n\n### Running DDL statements to manipulate metadata\n\n![Running CREATE statements to create a database and table](docs/run_ddl.gif)\n\nAthenai supports not only `SELECT`, `SHOW` and `DESCRIBE` statements, but also DDL statements such as `CREATE`, `ALTER` and `DROP`.\nYou can run any available DDL statements listed [here](http://docs.aws.amazon.com/athena/latest/ug/language-reference.html) to manipulate metadata.\n\nSince these statements usually show no results, the outputs of them are `(No output)` with query info, like the following:\n\n```\n$ athenai run \"CREATE DATABASE testdb\"\n⠳ Running query...\nQuery: CREATE DATABASE testdb;\n(No output)\nRun time: 0.41 seconds | Data scanned: 0 B\nLocation: s3://aws-athenai-demo/5fb06aaf-4123-49d0-b7fb-5876e99d788e.txt\n\n$ athenai run \u003c /tmp/create_table.sql\n⠦ Running query...\nQuery: CREATE EXTERNAL TABLE IF NOT EXISTS testdb.persons (\n  id INT,\n  name STRING,\n  age INT\n)\nROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'\nWITH SERDEPROPERTIES (\n  'separatorChar' = ',',\n  'quoteChar' = '\\\"',\n  'escapeChar' = '\\\\'\n)\nSTORED AS TEXTFILE\nLOCATION 's3://aws-athenai-demo/csv/';\n(No output)\nRun time: 0.95 seconds | Data scanned: 0 B\nLocation: s3://aws-athenai-demo/184344f3-3f6d-4fb9-9716-a89a7eb32ab6.txt\n\n$ athenai run \"SELECT * FROM testdb.persons\"\n⠴ Running query...\nQuery: SELECT * FROM testdb.persons;\n+----+---------+-----+\n| id | name    | age |\n|  1 | alice   |  20 |\n|  2 | bob     |  30 |\n|  3 | charlie |  40 |\n+----+---------+-----+\nRun time: 1.27 seconds | Data scanned: 51 B\nLocation: s3://aws-athenai-demo/36db3707-c0d7-416f-99af-aec3d6360583.csv\n```\n\n### Running multiple statements sequentially\n\n![Running multiple statements sequantially](docs/run_seq.gif)\n\nWhen you run multiple statements with Athenai, it runs up to 5 statements concurrently at a time by default, and subsequent statements are executed once prior ones have finished.\n\nSometimes, however, you may need to run each statement sequentially.\nFor example, suppose you are going to run the following 3 statements (`CREATE DATABASE` =\u003e `CREATE TABLE` =\u003e `SELECT`):\n\n##### sample.sql\n\n```sql\nCREATE DATABASE IF NOT EXISTS testdb;\n\nCREATE EXTERNAL TABLE IF NOT EXISTS testdb.persons (\n  id INT,\n  name STRING,\n  age INT\n)\nROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'\nWITH SERDEPROPERTIES (\n  'separatorChar' = ',',\n  'quoteChar' = '\\\"',\n  'escapeChar' = '\\\\'\n)\nSTORED AS TEXTFILE\nLOCATION 's3://aws-athenai-demo/csv/';\n\nSELECT * FROM testdb.persons;\n```\n\nIn these statements the second and third one depend on the previous one of each respectively, so they cannot be executed concurrently and need to be run sequentially.\n\nIn this case, you can specify the maximum number of concurrent query executions by using `--concurrent/-c` flag.\nTo run multiple statements sequentially, specify `--concurrent 1`:\n\n```\n$ athenai run --concurrent 1 \u003c sample.sql\n```\n\nThis command runs each statement sequentially and you should get the results you expect! 😄\n\n#### Caution\n\nAlthrough it is possible for you to specify max concurrency to more than 5 with `--concurrent/-c` flag, usually it is not recommended because the default concurrency limits are 5 concurrent DDL and SELECT statements at a time, as described in [Service Limits of Amazon Athena](http://docs.aws.amazon.com/athena/latest/ug/service-limits.html).\n\nThere is no problem if you have requested a limit increase for the limit, however 😉\n\n### Encrypting query results in Amazon S3\n\nYou can encrypt query results in Amazon S3 by running queries with `--encrypt/-e` flag.\nThe following encryption types are currently available.\n\n* [Amazon S3 server-side encryption with Amazon S3-managed keys](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html) (**`SSE_S3`**)\n* [Server-side encryption with KMS-managed keys](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html) (**`SSE_KMS`**)\n* [Client-side encryption with KMS-managed keys](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingClientSideEncryption.html) (**`CSE_KMS`**)\n\nIf you use `SSE_KMS` or `CSE_KMS`, you also need to provide your KMS key ARN or ID using `--kms/-k` flag.\n\nSee [EncryptionConfiguration data type on Amazon Athena API Reference](http://docs.aws.amazon.com/athena/latest/APIReference/API_EncryptionConfiguration.html) for more details about parameters for encryption configuration.\n\n##### Using Amazon S3 server-side encryption with Amazon S3-managed keys (`SSE_S3`)\n\n```\n$ athenai run --encrypt SSE_S3 ...\n```\n\n##### Using server-side encryption with KMS-managed keys (`SSE_KMS`)\n\n```\n$ athenai run --encrypt SSE_KMS --kms $YOUR_KMS_KEY_ARN_OR_ID ...\n```\n\n##### Using client-side encryption with KMS-managed keys (`CSE_KMS`)\n\n```\n$ athenai run --encrypt CSE_KMS --kms $YOUR_KMS_KEY_ARN_OR_ID ...\n```\n\n#### Note\n\nIf you want to make every query result executed by Athenai encrypted, I recommend you add these encryption configurations to your `$HOME/.athenai/config` file.\nFor example, to use `SSE_KMS` encryption type, add these lines into your `default` section:\n\n```ini\nencrypt = SSE_KMS\nkms = \u003cYOUR_KMS_KEY_ARN_OR_ID_HERE\u003e\n```\n\nIt eliminates the need of specifying the encryption flags every time and ensures your every query result will be encrypted with `SSE_KMS`.\n\n### Canceling queries\n\n![Canceling queries](docs/run_cancel.gif)\n\nYou can cancel queries by pressing `Ctrl-C` during the query executions.\n\n```\n$ athenai run \"SELECT * FROM sampledb.cloudfront_logs\"   # Oops! Full scan by mistake!\n⠖ Running query... ^C   # Press Ctrl-C\n⠋ Canceling...\n$ # Whew! That was close.\n```\n\nAthenai calls [StopQueryExecution API](http://docs.aws.amazon.com/athena/latest/APIReference/API_StopQueryExecution.html) to stop the query executions once `Ctrl-C` is pressed, so charges for the queries should stop too.\n\n### Showing results of completed query executions\n\n![Showing results of completed query executions](docs/show.gif)\n\n\nYou can show the results of completed query executions without re-running the same queries.\n\nRun the command below:\n\n```\n$ athenai show\n```\n\nand select query executions you want to show from the list with interactive filtering:\n\n```\nQUERY\u003e                                                                                                                                                IgnoreCase [48 (1/1)]\n2017-07-26 14:11:36 +0000 UTC   SHOW TABLES SUCCEEDED   0.37 seconds    0 B\n2017-07-26 14:11:36 +0000 UTC   SELECT timestamp, requestip, backendip FROM elb_logs LIMIT 3   SUCCEEDED   0.55 seconds    17.80 KB\n2017-07-26 14:11:36 +0000 UTC   SELECT date, time, bytes, requestip, method, status FROM cloudfront_logs LIMIT 10   SUCCEEDED   2.23 seconds    101.27 KB\n2017-07-26 14:11:36 +0000 UTC   SHOW DATABASES  SUCCEEDED   0.38 seconds    0 B\n(snip)\n```\n\nAthenai uses [peco/peco](https://github.com/peco/peco) as a library that performs interactive filtering.\nFrequently used key mappings are as follows:\n\nKey | Action\n:---:|---\n`↑`/`Ctrl-P` | Move up\n`↓`/`Ctrl-N` | Move down\n`Ctrl-Space` | Select/Unselect each entry\n`Ctrl-A` | Move cursor to the beginning of the line\n`Ctrl-E` | Move cursor to the end of the line\n`Ctrl-H` | Delete a character\n\nAvailable key mappings are listed [here](https://github.com/peco/peco#default-keymap).\nYou can select multiple entries by pressing `Ctrl-Space` on each entry.\n\n\nAfter you have selected the entries to show, hit `Enter` and you will see the results of selected query executions like the following:\n\n```\n$ athenai show\n⠋ Loading history...\n⠚ Fetching results...\nQuery: SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n+------------+----------+-------+-----------+--------+--------+\n| date       | time     | bytes | requestip | method | status |\n| 2014-08-05 | 15:56:57 |  4252 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:58 |  4257 | 10.0.0.3  | GET    |    200 |\n| 2014-08-05 | 15:56:58 |  4252 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:58 |  4251 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:59 |    10 | 10.0.0.15 | GET    |    304 |\n+------------+----------+-------+-----------+--------+--------+\nRun time: 2.03 seconds | Data scanned: 101.82 KB\nLocation: s3://aws-athenai-demo/836b5b3f-5fdd-447f-9b02-dc869bc8d03d.csv\n⠞ Fetching results...\nQuery: SHOW DATABASES;\n+-----------------+\n| cloud_trail     |\n| cloudfront_logs |\n| default         |\n| elb_logs        |\n| s3_logs         |\n| sampledb        |\n+-----------------+\nRun time: 0.38 seconds | Data scanned: 0 B\nLocation: s3://aws-athenai-demo/c572a884-1cba-472d-a568-ac8e1e75551b.txt\n```\n\nBy default the `show` command lists up to the latest 50 query executions except for ones in `FAILED` state.\nYou can configure the number by specifying `--count/-c` flag:\n\n```\n$ athenai show --count 100   # Lists up to the latest 100 query executions\n```\n\nIf you want to list all of your completed query executions, specify `0`:\n\n```\n$ athenai show --count 0\n```\n\nNote that `athenai show --count 0` may be very slow depending on the total number of your query executions.\n\n### Printing results in CSV format\n\n![Printing results in CSV format](docs/format_csv.gif)\n\nIf you want to print query results in CSV format instead of table format, specify `--format/-f csv` flag.\n\n```\n$ athenai run --format csv \"SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\"\n⠲ Running query...\nQuery: SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\ndate,time,bytes,requestip,method,status\n2014-07-05,15:00:00,4260,10.0.0.15,GET,200\n2014-07-05,15:00:00,10,10.0.0.15,GET,304\n2014-07-05,15:00:00,4252,10.0.0.15,GET,200\n2014-07-05,15:00:00,4257,10.0.0.8,GET,200\n2014-07-05,15:00:03,4261,10.0.0.15,GET,200\nRun time: 2.20 seconds | Data scanned: 101.27 KB\nLocation: s3://aws-athenai-demo/ad90ad38-15fe-4f61-9c0d-2a648bb2f8f3.csv\n```\n\nYou can also use this flag with `athenai show` command.\n\n```\n$ athenai show --format csv\n⠳ Loading history...\n⠚ Fetching results...\nQueryExecutionId: 7226c8a5-c3b6-4399-97fb-ea7683e774d1\nQuery: SELECT date, time, bytes, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\ndate,time,bytes,requestip,method,status\n2014-07-05,15:00:00,4260,10.0.0.15,GET,200\n2014-07-05,15:00:00,10,10.0.0.15,GET,304\n2014-07-05,15:00:00,4252,10.0.0.15,GET,200\n2014-07-05,15:00:00,4257,10.0.0.8,GET,200\n2014-07-05,15:00:03,4261,10.0.0.15,GET,200\nRun time: 1.90 seconds | Data scanned: 101.27 KB\n```\n\n### Outputting (Saving) results to file\n\n![Outputting (Saving) results to a file](docs/run_output.gif)\n\nIf you want to output (save) the query results to a file, use `--output/-o` flag to specify the file path:\n\n```\n$ athenai run --output /tmp/results.txt \"SELECT date, time, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\"\n⠙ Running query...\n$ cat /tmp/results.txt\n\nQuery: SELECT date, time, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n+------------+----------+-----------+--------+--------+\n| date       | time     | requestip | method | status |\n| 2014-08-05 | 15:56:57 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:58 | 10.0.0.3  | GET    |    200 |\n| 2014-08-05 | 15:56:58 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:58 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:59 | 10.0.0.15 | GET    |    304 |\n+------------+----------+-----------+--------+--------+\nRun time: 2.41 seconds | Data scanned: 101.82 KB\nLocation: s3://aws-athenai-demo/62af0cf0-9417-47d4-a0c0-19250dce59a8.csv\n```\n\nor just redirect stdout to a file:\n\n```\n$ athenai run \"SELECT date, time, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\" \u003e /tmp/results.txt\n⠙ Running query...\n$ cat /tmp/results.txt\n\nQuery: SELECT date, time, requestip, method, status FROM sampledb.cloudfront_logs LIMIT 5;\n+------------+----------+-----------+--------+--------+\n| date       | time     | requestip | method | status |\n| 2014-08-05 | 15:56:57 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:58 | 10.0.0.3  | GET    |    200 |\n| 2014-08-05 | 15:56:58 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:58 | 10.0.0.15 | GET    |    200 |\n| 2014-08-05 | 15:56:59 | 10.0.0.15 | GET    |    304 |\n+------------+----------+-----------+--------+--------+\nRun time: 2.23 seconds | Data scanned: 101.82 KB\nLocation: s3://aws-athenai-demo/be70bc11-6234-4960-ab81-608749c3a4b8.csv\n```\n\n\n## Configuration file\n\nYou can save your configurations into `$HOME/.athenai/config` file to simplify every command execution.\n\n### File format\n\nAthenai's configuration file has simple INI file format.\nHere are available settings:\n\n```ini\n# Section name\n[default]\n# Profile in your $HOME/.aws/credentials file\n# Default: default\nprofile = default\n\n# AWS region\n# Default: us-east-1\nregion = us-east-1\n\n# Database name\ndatabase = sampledb\n\n# Output location in S3 where query results will be stored\nlocation = s3://aws-athena-query-results-\u003cYOUR_ACCOUNT_ID\u003e-us-east-1/\n\n# Encryption configuration for query results\n## Encryption type\n## Valid values: SSE_S3, SSE_KMS, CSE_KMS\nencrypt = SSE_KMS\n## KMS key ARN or ID used for SSE_KMS or CSE_KMS\nkms = \u003cYOUR_KMS_KEY_ARN_OR_ID\u003e\n\n# Turn on debug logging\n# Default: false\ndebug = false\n\n# Do not show informational messages\n# Default: false\nsilent = false\n\n# Output query results to a given file path instead of stdout\noutput = /path/to/file\n\n# The formatting style for query results\n# Valid values: table, csv\n# Default: table\nformat = table\n\n# The maximum possible number of SUCCEEDED query executions to list\n# Default: 50\ncount = 50\n```\n\n**The `[default]` section is required since Athenai uses config values inside the section by default.**\n\nYou can optionally add other sections into your file. For example, add `[oregon]` section as follows:\n\n```ini\n[default]\nprofile = default\nregion = us-east-1\ndatabase = sampledb\nlocation = s3://aws-athena-query-results-\u003cYOUR_ACCOUNT_ID\u003e-us-east-1/\n\n # Section for us-west-2\n[oregon]\n# Use another profile\nprofile = myuser\n# Use us-west-2 region\nregion = us-west-2\n# I created the database in us-west-2\ndatabase = elb_logs\n# Save your query results into your other bucket\nlocation = s3://my-elb-logs-query-results/\n```\n\nand then use `--section/-s` flag to specify the section to use:\n\n```\n$ athenai run --section oregon \"SHOW DATABASES\"\n⠚ Running query...\nQuery: SHOW DATABASES;\n+----------+\n| default  |\n| elb_logs |\n| sampledb |\n+----------+\nRun time: 0.39 seconds | Data scanned: 0 B\nLocation: s3://my-elb-logs-query-results/401e35ec-6b91-4bbf-a45f-bd144b17e199.txt\n```\n\nNote that you can also specify all of the above configuration values via command line flags when running a command.\nSee each command's `--help` message for more details.\n\n### Location of configuration file\n\nBy default Athenai loads `$HOME/.athenai/config` automatically and use values in the file.\nIf Athenai cannot find or fails to load the config file at the location, it ignores the file and uses command line flags only.\n\nIf you want to use another config file at another location, use `--config` flag to specify its path (also don't forget to specify `--section` unless `default`):\n\n```\n$ cat /tmp/myconfig\n[oregon]\nprofile = myuser\nregion = us-west-2\ndatabase = elb_logs\nlocation = s3://my-elb-logs-query-results/\n\n$ athenai run --config /tmp/myconfig --section oregon \"SHOW DATABASES\"\n⠳ Running query...\nQuery: SHOW DATABASES;\n+----------+\n| default  |\n| elb_logs |\n| sampledb |\n+----------+\nRun time: 0.28 seconds | Data scanned: 0 B\nLocation: s3://my-elb-logs-query-results/3334a6f3-2de1-4e6b-b144-32de59645cee.txt\n```\n\n### Note: precedence of configuration values\n\n**Command line flags have higher priority than config file**, so if you specify flags explicitly when running a command, values in the config file are overridden by the flags.\n\n\n## Bug report \u0026 feature request\n\nFeel free to open an issue if you encounter any problem or have a feature request! 😄\n\nHowever, in order to solve your issue quickly and avoid duplicate effort, please follow the steps below.\n\n1. Search a similar issue already reported [here](https://github.com/skatsuta/athenai/issues?utf8=%E2%9C%93\u0026q=is%3Aissue).\n1. If it exists, add your comment or [Reaction (for +1)](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments).\n1. If it doesn't exist, [create a new issue](https://github.com/skatsuta/athenai/issues/new) and describe the details.\n\n\n## Contributing\n\nYour contributions are always welcome! 😆\n\nPlease follow the steps below to fix a bug or add a new feature, etc.\n\n1. [Fork the original repo](https://github.com/skatsuta/athenai/fork)\n1. **Clone the ORIGINAL repo (NOT your fork)**\n   ```\n   $ git clone https://github.com/skatsuta/athenai.git\n   ```\n1. **Add your fork as a new remote named `fork`**\n   ```\n   $ git remote add fork https://github.com/yourname/athenai.git\n   ```\n1. Create your bug fix or feature branch\n   ```\n   $ git checkout -b your-working-branch\n   ```\n1. Update the code, add tests if necessary and make sure all tests pass\n   ```\n   $ ./scripts/test.sh\n   ```\n1. Commit your changes\n\n   Please describe the details of your commit in the commit message and include a corresponding GitHub issue number if it exists.\n\n1. **Push to the `fork` (NOT to the `origin`)**\n   ```\n   $ git push fork\n   ```\n1. Create a new pull request against the `master` branch\n\n\n## License\n\n[Apache License 2.0](https://github.com/skatsuta/athenai/blob/master/LICENSE)\n\n\n## Author\n\n[Soshi Katsuta (skatsuta)](https://github.com/skatsuta)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskatsuta%2Fathenai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskatsuta%2Fathenai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskatsuta%2Fathenai/lists"}