Crates.io | piqel |
lib.rs | piqel |
version | 0.202107.4 |
source | src |
created_at | 2021-07-08 03:02:17.978777 |
updated_at | 2021-07-14 15:31:41.450238 |
description | A implementation of PartiQL |
homepage | https://github.com/fuyutarow/piqel |
repository | https://github.com/fuyutarow/piqel.git |
max_upload_size | |
id | 420145 |
size | 31,586,707 |
[tests.hello]
script = '''
cat<<EOS | pq -q "SELECT NAME, LOGNAME" -t json
{
"SHELL": "/bin/bash",
"NAME": "my machine name",
"PWD": "/home/fuyutarow/piqel",
"LOGNAME": "fuyutarow",
"HOME": "/home/fuyutarow",
"LANG": "C.UTF-8",
"USER": "fuyutarow",
"HOSTTYPE": "x86_64",
"_": "/usr/bin/env"
}
EOS
'''
tobe = '''
[
{
"NAME": "my machine name",
"LOGNAME": "fuyutarow"
}
]
'''
content | lang | package |
---|---|---|
pq | CLI (brew, scoop) | |
piqel | Rust (cargo) | https://crates.io/crates/piqel |
piqel-js | JavaScript (npm) | https://www.npmjs.com/package/piqel |
piqel-py | Python (pip) | https://pypi.org/project/piqel |
What’s PartiQL?
option | description |
---|---|
-c, --compact | compact instead of pretty-printed output, only when outputting in JSON |
-S, --sort-keys | sort keys of objects on output. it on works when --to option is json, currently |
curl -s "https://api.github.com/repos/fuyutarow/piqel/commits?per_page=1" | pq
option | description |
---|---|
-f, --from |
target config file [possible values: csv, json, toml, yaml, xml] |
-t, --to |
target config file [possible values: csv, json, toml, yaml, xml] |
use -t
option c to convert Json, Yaml, Toml, and XML to each other.
cat pokemon.json | pq -t yaml
cat pokemon.json | pq -t yaml | pq -t toml
Comparison with existing command yj[1]
format | pq | yj |
---|---|---|
JSON | ✅ | ✅ |
TOML | ✅ | ⚠️*1 |
YAML | ✅ | ✅ |
XML | ✅ | ✅ |
CSV | ✅ | ❌ |
*1 TOML of the following format cannot be serialized with yj
, but it can be serialized with pq
by replacing the fields accordingly.
{
"name": "partiql-pokemon",
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"license": "MIT"
}
option | description |
---|---|
-q |
クエリ |
query | description |
---|---|
SELECT <field_path> |
|
SELECT <field_path> AS <alias_path> |
curl -s https://raw.githubusercontent.com/fuyutarow/pokemon.json/master/en/pokemon.json | pq -q "SELECT name, weight/height/height AS bmi ORDER BY bmi DESC LIMIT 20"
curl https://partiql-pokemon.vercel.app/api/pokemon/ja -G --data-urlencode "q= SELECT name, weight/height/height AS bmi ORDER BY bmi DESC LIMIT 20"
brew install fuyutarow/tap/pq
pq -h
scoop install pq
pq -h
env | jo | pq "SELECT NAME AS name, USER AS user"
ip
command is only available in Linux and WSL, not in Mac.
ip -j -p | pq "$(cat<<EOS
SELECT
address,
info.family AS inet,
info.local
FROM addr_info AS info
WHERE inet LIKE 'inet%'
EOS
)"
Use tests-make to test CLI pq
.
brew install fuyutarow/tap/tests-make
tests-make tests-make/index.toml
or
makers test:pq
content | test | command |
---|---|---|
pq | test | makers test:pq |
piqel | test | makers test:lib |
piqel-js | test | makers test:js |
piqel-py | test | makres test:py |
all | makers test |
cargo install cargo-kcov
cargo kcov
or
makers cov
makers install-dev
makers build
makers build:pq ;: for pq commnad
jq[2] approach
curl -s "https://api.github.com/repos/fuyutarow/piqel/commits?per_page=1" | jq ".[].commit.author"
gron[3] approach
curl -s "https://api.github.com/repos/fuyutarow/piqel/commits?per_page=1" | gron | grep "commit.author" | gron -u
nusehll[4] approach
curl -s "https://api.github.com/repos/fuyutarow/piqel/commits?per_page=1" | from json | get commit.author | to json
pq[5] approach
curl -s "https://api.github.com/repos/fuyutarow/piqel/commits?per_page=1" | pq -q "SELECT commit.author"
https://github.com/sagiegurari/cargo-make … Run cargo install cargo-make
to use makers
commnad. ↩︎