tosql - run sql queries on CLI data
tosql is a cli tool for running SQL queries on CLI data and outputting results to json
format. It can read/write from stdin/stdout so it should work fairly naturally.
It can also perform joins for data that comes from multiple input files.
Setup
Install via pip:
pip install tosql
Quick Start
Pipe any tabular data in and use tosql to run a sql query on it. The default table
name to select from is "a"
df | tosql "SELECT * FROM a LIMIT 2"
If you run tosql with no arguments it will "SELECT * FROM a" by default.
df | tosql
Joins
tosql reads multiple input files into tables called a,b,c,... , which you can perform join on.
For example:
# join a csv of daily prices with a json file of sales on different days
tosql -i examples/daily-price.csv -i examples/daily-sells.json "SELECT a.Open as price, b.amount, b.day FROM a JOIN b ON a.Date = b.day LIMIT 10"
# calculate the total sold
tosql -i examples/daily-price.csv -i examples/daily-sells.json "SELECT SUM(Open*amount) FROM a JOIN b ON a.Date = b.day"
CLI Options
tosql has several command line options to choose from, displyed by running with the
"--help" flag.
$ tosql --help
Usage: tosql [OPTIONS] [SQL]
Options:
--version Show the version and exit.
-i, --input FILENAME Input file, default stdin
-o, --output TEXT Output file, default stdout
-f, --sql-file TEXT File containing SQL query
-t, --table-name TEXT Table name [default: df]
-c, --cols TEXT Column names, comma separated
--auto Autogenerate column names: a b c ...
--save Save the sql file to .tosql.db
--help Show this message and exit.
Metadata
Release files for tosql 0.2.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 | Provenance | Actions |
|---|---|---|---|---|
| tosql-0.2.1.tar.gz | 5.8 kB | Without provenance | Details for tosql-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tosql-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for tosql-0.2.1-py3-none-any.whl |
Total release size: 10.7 kB
Release files / tosql-0.2.1.tar.gz
| Download URL | tosql-0.2.1.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef82e6fa855925634d89cb996025500d760205c459c84c4dbd66237abcc91293
|
|
BLAKE2b-256 checksum How to use checksums |
c8d1c7a8aebd171c51ff3115e244630869080f8bfea9c46009b1b74823908ec2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.9
|
Release files / tosql-0.2.1-py3-none-any.whl
| Download URL | tosql-0.2.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f45273d2ec5ba1c2584d92dd2ee6c4a432095d1d195c90e1c41663f8813cfcc6
|
|
BLAKE2b-256 checksum How to use checksums |
25b200f86348303d15ec957a1b5d6ee48f556bfc7f67076179694802435f438e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.9
|
Security for tosql 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.