Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fuyutarow/piqel
An implementation of PartiQL written in Rust
https://github.com/fuyutarow/piqel
partiql query-language rust sql
Last synced: 3 months ago
JSON representation
An implementation of PartiQL written in Rust
- Host: GitHub
- URL: https://github.com/fuyutarow/piqel
- Owner: fuyutarow
- Created: 2021-05-20T20:41:39.000Z (over 3 years ago)
- Default Branch: alpha
- Last Pushed: 2022-08-24T07:41:08.000Z (over 2 years ago)
- Last Synced: 2024-10-11T20:37:05.098Z (3 months ago)
- Topics: partiql, query-language, rust, sql
- Language: Rust
- Homepage: https://piqel.pages.dev
- Size: 1.7 MB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Document(WIP)
A command line tool for data processing with SQL queries. json, yaml, toml to your favorite format.
Family
language
source, docs
packagepq
CLI (brew, scoop)
source, docpiqel
Rust (cargo)
source, doc
https://crates.io/crates/piqelpiqel-js
JavaScript (npm)
source, doc
https://www.npmjs.com/package/piqelpiqel-py
Python (pip)
source, doc
https://pypi.org/project/piqelTable of Contants
Features
- SQL-like query … You can use SELECT, WHERE, ORDER BY, LIMIT clauses to select and transform data.
- Supported data format … CSV, JSON, YAML, TOML. Table data as used in RDB and structured data such as JSON cab be accessed by SQL-like query.
- Wide range of uses … This can be used as a CLI tool (pq), as a PartiqQL server with piqel(rust) or piqel-js, or data analysis with piqel-py.
Motivation
What’s PartiQL?
Usage
pretty print
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
convert file format
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>
Calculate BMI
- Download the file and then calculate BMI in a local.
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"
- In a terminal, send a query to the server to calculate BMI in a remote.
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"
- In a web browser, send a query to the server to calculate BMI in a remote.
partiql-pokemon.vercel.app/api/pokemon/en?q= SELECT name, weight/height/height AS bmi ORDER BY bmi DESC LIMIT 20
Installation
brew install fuyutarow/tap/pq
pq -h
scoop install pq
pq -h
Convert data
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
)"
- [x] SELECT
- [x] FROM
- [x] LEFT JOIN
- [x] WHERE
- [x] LIKE
- [x] ORDER BY
- [x] LIMIT
Test
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
all
makers test
code coverage
cargo install cargo-kcov
cargo kcov
or
makers cov
Preparation
makers install-dev
build
makers build
makers build:pq ;: for pq commnad
LICENCE
Appendix
Comparison of tools that can extract fields
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"
utils
- makers[6]
-
https://github.com/sclevine/yj ↩︎
-
https://github.com/stedolan/jq ↩︎
-
https://github.com/tomnomnom/gron ↩︎
-
https://github.com/nushell/nushell ↩︎
-
https://github.com/fuyutarow/piqel ↩︎
-
https://github.com/sagiegurari/cargo-make … Run
cargo install cargo-make
to usemakers
commnad. ↩︎