Shelect: SQL for local files
Shelect lets you run SQL on data in your local filesystem.
Use it for easy, local ad-hoc analysis of CSV/TSV/JSON files.
It supports all functions and SQL syntax supported by SQLite.
How to use it
$ shelect 'SELECT * FROM "./examples/people.csv"'
id | name
---+-------
1 | Alice
2 | Bob
3 | Carlos
4 | Dani
$ shelect 'SELECT * FROM "./examples/values.json"'
id | value
---+------
1 | 10
2 | 20
3 | 30
3 | 40
$ shelect 'SELECT * FROM "./examples/values.json" JOIN "./examples/people.csv" USING (id)'
id | value | name
---+-------+-------
1 | 10 | Alice
2 | 20 | Bob
3 | 30 | Carlos
3 | 40 | Carlos
$ shelect 'SELECT name, sum(value) FROM "./examples/people.csv" LEFT JOIN "./examples/values.json" USING (id) GROUP BY 1'
name | SUM(value)
-------+-----------
Alice | 10
Bob | 20
Carlos | 70
Dani | NULL
It also can function as a repl when invoked without a query.
How it works
An in-memory SQLite database is created. Before executing each query, the query is parsed and all tables accessed are first imported from the filesystem into a table with that name.
So if you run SELECT * from "./my-file.csv" a table named "./my-file.csv" will be created by opening ./my-file.csv
and attempting to read it as JSON, CSV, or TSV.
JSON files must be arrays of objects, where each object is a key-value mapping where keys correspond to column names.
CSV and TSV files must have a single row with column names followed by data rows.
All columns are created as TEXT data types. Please refer to the SQLite documentation for supported SQL functions and
functionality.
How to install
shelect is on pypi: https://pypi.org/project/shelect/
Via pipx:
$ pipx install shelect
Via pip:
$ python3 -m pip install shelect
Release files for shelect 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shelect-0.1.1.tar.gz | 8.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shelect-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:19.3 kB
Release files / shelect-0.1.1.tar.gz
| Download URL | shelect-0.1.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c30430ad2f43d83d6078c371ac827c6aa3ba5151e638f027b45576ea245d891
|
|
BLAKE2b-256 checksum How to use checksums |
ba9cf5da534dd03f42bee48a205bb23919d9001f46f5f014d45a42f9aec99ee9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Release files / shelect-0.1.1-py3-none-any.whl
| Download URL | shelect-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
537da5ccd64c40604ed5cf932358cb4ba06ad24397efad0cec17528d057b94fa
|
|
BLAKE2b-256 checksum How to use checksums |
63de6a4928e97635d484867f9a106fd30beadbe96b8066b24e17c9a2d913c43b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|