aws athena的presto-like cli

athena-cli的Python项目详细描述


雅典娜

Build Status

用于AWS Athena的类似presto的cli工具。另一种方法是使用 aws客户端Athena sub-commands

asciicast

要求

路径上必须有最新版本的awscli。

安装

要使用pip安装,请运行:

$ pip install athena-cli

或者,克隆github repo并运行:

$ python setup.py install

配置

唯一需要的配置是aws凭据。

用法

$ 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 [, ...]

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

示例

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

故障排除

启动athenacli时使用--debug选项可获得aws调试输出:

$ 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
...

通过键入:

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

命令历史记录写入~/.athena_history

类似项目

  • AthenaCLI:aws雅典娜服务的cli工具,可以自动完成和语法突出显示。
  • athena-cli (Ruby):用于amazon athena的cli,由jruby提供支持。

参考文献

许可证

Athena CLI
Copyright 2017-2018 Guardian News & Media
Copyright 2019 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.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
数组Java For Loop没有输出(我认为)它应该如何输出   java Maven可以在一个模块中打包两个jar,使用相同的文件名但不同的图表集吗?   java OData读取单个实体最佳实践   java为什么我的代码在以下条件下返回false?   java QueryDsl投影元素集合   在为Java Swing元素实现ActionListener时,如何解决静态引用错误?   libGDX设置允许我使用java8,它在Android中崩溃   如何将日期从shell脚本传递到java即时数据类型   java如何向JList添加复选框和图像   java如何编写这个Listview?   java Eclipse每项目构建设置   java如何将spring引导应用程序指向外部jar的logback。xml   java更改EditText的下划线/样式。。。。。不是链接,而是水平滚动文本   java JPQL:使用复合键建模具有多个关系的查询实体   javascript如何获取Java中的最后32个字节   sql检查Java Derby中是否存在架构   java如何从视图中获取MVC Spring控制器中jstl select的所有项   java gson在需要对象时遇到空数组问题