Skip to main content

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:

  1. Clone this repo
  2. Change into the directory
  3. pip3 install .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shelect-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shelect-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

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

Hashes for shelect-0.1.0.tar.gz
Algorithm Hash digest
SHA256 da250092032ea79ec8c4cd7932e2da1a59c26fa46c65f24fdddc949eb7d9b763
MD5 af5238fb048995aa18f810f4c6705d3c
BLAKE2b-256 0c50e043c5b65855fc1d996cbaf6edab31beec95b1a6735fd41ce8ba02781eee

See more details on using hashes here.

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

Hashes for shelect-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc8cbfb3237d97ca6685e609ff35db98990573d01e575f0a113ba85e43530fcd
MD5 6392c99a1c01a6f9b7f3b428de2b1c7f
BLAKE2b-256 01bc65ce9b3d298b9b3ece4ba9ba92d9cc05464698e7e41412c9b50015056b05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page