Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flowerinthenight/athena2csv
Query AWS Athena and download the result as CSV.
https://github.com/flowerinthenight/athena2csv
athena csv go golang s3 sql
Last synced: 8 days ago
JSON representation
Query AWS Athena and download the result as CSV.
- Host: GitHub
- URL: https://github.com/flowerinthenight/athena2csv
- Owner: flowerinthenight
- License: mit
- Created: 2019-03-09T14:31:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-11T18:43:49.000Z (about 3 years ago)
- Last Synced: 2024-06-20T12:00:49.311Z (5 months ago)
- Topics: athena, csv, go, golang, s3, sql
- Language: Go
- Homepage:
- Size: 725 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CircleCI](https://circleci.com/gh/flowerinthenight/athena2csv/tree/master.svg?style=svg)](https://circleci.com/gh/flowerinthenight/athena2csv/tree/master)
## Overview
This tool can download an [Athena](https://aws.amazon.com/athena/) SQL query results in CSV format.## Installation
Using [Homebrew](https://brew.sh/):
```bash
$ brew tap flowerinthenight/tap
$ brew install athena2csv
```If you have a Go environment:
```bash
$ go get -u -v github.com/flowerinthenight/athena2csv
```## Run the tool
Running this tool will create an [S3 bucket](https://aws.amazon.com/s3/) `queryathena2csv-query-bucket`.Required environment variables:
```bash
# 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:
```bash
$ athena2csv --database aws-billing --query-file query.txt
```If your query is not that long, you can input directly in command line:
```bash
$ 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`.