19 个版本 (12 个稳定版)
4.0.1 | 2024年2月11日 |
---|---|
3.0.2 | 2024年2月10日 |
2.0.1 | 2022年7月3日 |
1.2.3 | 2022年1月3日 |
0.5.1 | 2019年11月24日 |
#2 在 #rds
每月下载量 146
32KB
355 代码行
通过命令行查询 AWS RDS 数据
安装
通过shell脚本安装预构建的二进制文件
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/bruceadams/query-rds-data/releases/latest/download/query-rds-data-installer.sh | sh
通过powershell脚本安装预构建的二进制文件
irm https://github.com/bruceadams/query-rds-data/releases/latest/download/query-rds-data-installer.ps1 | iex
将预构建的二进制文件安装到您的npm项目中
npm install query-rds-data
或使用 npx
安装并运行二进制文件
npx query-rds-data --help
通过Homebrew安装预构建的二进制文件
brew install bruceadams/homebrew-utilities/query-rds-data
通过cargo binstall安装预构建的二进制文件
cargo binstall query-rds-data
下载
文件 | 平台 | 校验和 |
---|---|---|
query-rds-data-aarch64-apple-darwin.tar.gz | macOS Apple Silicon | 校验和 |
query-rds-data-x86_64-apple-darwin.tar.gz | macOS Intel | 校验和 |
query-rds-data-x86_64-pc-windows-msvc.zip | Windows x64 | 校验和 |
query-rds-data-x86_64-unknown-linux-gnu.tar.gz | Linux x64 | 校验和 |
query-rds-data-x86_64-unknown-linux-musl.tar.gz | musl Linux x64 | 校验和 |
query-rds-data-x86_64-pc-windows-msvc.msi | Windows x64 | 校验和 |
构建
这是一个简单的 Rust 项目,使用 Cargo。安装 Rust (强烈推荐使用 Rustup) 后,只需运行 cargo build
即可。
内置帮助
$ cargo build # The first build takes longer, with more output
Finished dev [unoptimized + debuginfo] target(s) in 0.22s
$ target/debug/query-rds-data --help
Query AWS RDS Data from the command line
You can set the environment variable `RUST_LOG` to adjust
logging, for example `RUST_LOG=trace query-rds-data`.
Usage: query-rds-data [OPTIONS] <QUERY>
Arguments:
<QUERY>
SQL query
Options:
-p, --profile <PROFILE>
AWS source profile to use. This name references an
entry in ~/.aws/config
[env: AWS_PROFILE=]
-r, --region <REGION>
AWS region to target
[env: AWS_REGION=]
-c, --db-cluster-identifier <CLUSTER_ID>
RDS cluster identifier
[env: AWS_RDS_CLUSTER=]
-u, --db-user-identifier <USER_ID>
RDS user identifier (really the AWS secret identifier)
[env: AWS_RDS_USER=]
-f, --format <FORMAT>
Output format
[default: csv]
Possible values:
- csv: CSV output, including a header line
- json: A JSON Object. For example:
{"numberOfRecordsUpdated": 0, "records": [{"id": 1,
"name": "bruce", "amount": 0.05}]}
-d, --database <DATABASE>
Database name
[env: AWS_RDS_DATABASE=]
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
错误消息
希望 query-rds-data
的错误消息能帮助您找出问题所在以及如何解决问题。
# No RDS instances exist
$ query-rds-data "select * from db1.names"
Error: No DBs found
$ query-rds-data "select * from db1.names" --db-cluster-identifier nope
Error: No DB matched "nope", available ids are []
# Single RDS instance exists
$ query-rds-data "select * from db1.names" --db-cluster-identifier nope
Error: No DB matched "nope", available ids are ["demo"]
# No credentials in AWS Secrets Manager
$ query-rds-data "select * from db1.names"
Error: No DB user secrets found
$ query-rds-data "select * from db1.names" --db-user-identifier fake
Error: No DB user matched "fake", available users are []
# Single secret exists for this database
$ query-rds-data "create database db1"
""
$ query-rds-data "create table db1.names (id int, name varchar(64))"
""
$ query-rds-data "insert into db1.names values (1,'Bruce')"
""
$ query-rds-data "select * from db1.names"
id,name
1,Bruce
$ query-rds-data "select * from information_schema.tables where table_schema='db1'"
TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,VERSION,ROW_FORMAT,TABLE_ROWS,AVG_ROW_LENGTH,DATA_LENGTH,MAX_DATA_LENGTH,INDEX_LENGTH,DATA_FREE,AUTO_INCREMENT,CREATE_TIME,UPDATE_TIME,CHECK_TIME,TABLE_COLLATION,CHECKSUM,CREATE_OPTIONS,TABLE_COMMENT
def,db1,names,BASE TABLE,InnoDB,10,Compact,0,0,16384,0,0,0,NULL,NULL,NULL,NULL,latin1_swedish_ci,NULL,,
# Explicit cluster and user names can be used
$ query-rds-data "select * from db1.names" --db-cluster-identifier demo
id,name
1,Bruce
$ query-rds-data "select * from db1.names" --db-user-identifier admin
id,name
1,Bruce
$ query-rds-data "select * from db1.names" --db-cluster-identifier demo --db-user-identifier admin
id,name
1,Bruce
# Names that are not found list what is available to be selected
$ query-rds-data "select * from db1.names" --db-cluster-identifier nope
Error: No DB matched "nope", available ids are ["demo"]
$ query-rds-data "select * from db1.names" --db-user-identifier fake
Error: No DB user matched "fake", available users are ["admin"]
# If there are multiple clusters or users available, you must select one
$ query-rds-data "select * from db1.names"
Error: Multiple DBs found, please specify one of ["demo", "empty"]
$ query-rds-data "select * from db1.names" --db-cluster-identifier demo
Error: Multiple DB users found, please specify one of ["admin", "read_only"]
$ query-rds-data "select * from db1.names" --db-cluster-identifier demo --db-user-identifier read_only
id,name
1,Bruce
依赖项
~52MB
~753K SLoC