Skip to content
Query AWS Athena and download the result as CSV.
Branch: master
Clone or download
Latest commit a9f1b8e Mar 10, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci add ci Mar 9, 2019
.gitignore initial commit Mar 9, 2019
LICENSE Initial commit Mar 9, 2019
README.md Update README.md Mar 10, 2019
go.mod update mod Mar 9, 2019
go.sum update mod Mar 9, 2019
main.go update mod Mar 9, 2019
query.txt simple query Mar 9, 2019

README.md

CircleCI

Overview

This tool can download an Athena SQL query results in CSV format.

Installation

$ go get -u -v github.com/flowerinthenight/athena2csv

Or you can clone and build:

$ git clone https://github.com/flowerinthenight/athena2csv
$ cd athena2csv/
$ go build -v

Run the tool

Running this tool will create an S3 bucket queryathena2csv-query-bucket.

Required environment variables:

# The following should have at least Athena read and S3 read/write access.
AWS_REGION={your-aws-region}
AWS_ACCESS_KEY_ID={aws-key-id}
AWS_SECRET_ACCESS_KEY={aws-secret}

If your query string is quite long, you can write it in a file:

$ athena2csv --database aws-billing --query-file query.txt

If your query is not that long, you can input directly in command line:

$ athena2csv --database aws-billing "select \"identity/lineitemid\" \
      from \"aws_billing\".\"mobingilabs_aws_billing_formatted_development\" \
      limit 10"

Output file is downloaded to the current directory, named output.csv.

You can’t perform that action at this time.