SQL for your local CSV/JSON files
Project description
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
Right now, assuming you have python3 installed:
- Clone this repo
- Change into the directory
pip3 install .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shelect-0.1.0.tar.gz.
File metadata
- Download URL: shelect-0.1.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da250092032ea79ec8c4cd7932e2da1a59c26fa46c65f24fdddc949eb7d9b763
|
|
| MD5 |
af5238fb048995aa18f810f4c6705d3c
|
|
| BLAKE2b-256 |
0c50e043c5b65855fc1d996cbaf6edab31beec95b1a6735fd41ce8ba02781eee
|
File details
Details for the file shelect-0.1.0-py3-none-any.whl.
File metadata
- Download URL: shelect-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc8cbfb3237d97ca6685e609ff35db98990573d01e575f0a113ba85e43530fcd
|
|
| MD5 |
6392c99a1c01a6f9b7f3b428de2b1c7f
|
|
| BLAKE2b-256 |
01bc65ce9b3d298b9b3ece4ba9ba92d9cc05464698e7e41412c9b50015056b05
|