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

shelect is on pypi: https://pypi.org/project/shelect/

Via pipx:

$ pipx install shelect

Via pip:

$ python3 -m pip install shelect

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.1.tar.gz (8.8 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.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file shelect-0.1.1.tar.gz.

File metadata

  • Download URL: shelect-0.1.1.tar.gz
  • Upload date:
  • Size: 8.8 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.1.tar.gz
Algorithm Hash digest
SHA256 3c30430ad2f43d83d6078c371ac827c6aa3ba5151e638f027b45576ea245d891
MD5 8a904e22ec3c756138cdb6121033055b
BLAKE2b-256 ba9cf5da534dd03f42bee48a205bb23919d9001f46f5f014d45a42f9aec99ee9

See more details on using hashes here.

File details

Details for the file shelect-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: shelect-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 537da5ccd64c40604ed5cf932358cb4ba06ad24397efad0cec17528d057b94fa
MD5 c92f828e98b9a3abefa096303054198b
BLAKE2b-256 63de6a4928e97635d484867f9a106fd30beadbe96b8066b24e17c9a2d913c43b

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