All Projects → itchyny → qhs

itchyny / qhs

Licence: MIT license
SQL queries on CSV and TSV files

Programming Languages

haskell
3896 projects
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to qhs

Postguard
🐛 Statically validate Postgres SQL queries in JS / TS code and derive schemas.
Stars: ✭ 104 (+235.48%)
Mutual labels:  sql-query
Archery
SQL 审核查询平台
Stars: ✭ 3,279 (+10477.42%)
Mutual labels:  sql-query
Csv
CSV data manipulation made easy in PHP
Stars: ✭ 2,863 (+9135.48%)
Mutual labels:  csv-converter
Ship Hold
data access framework for Postgresql on nodejs
Stars: ✭ 110 (+254.84%)
Mutual labels:  sql-query
Sublimetext Sqltools
SQLTools for Sublime Text 3
Stars: ✭ 166 (+435.48%)
Mutual labels:  sql-query
comma splice
Fixes CSVs with unquoted commas in values
Stars: ✭ 67 (+116.13%)
Mutual labels:  csv-converter
Deveeldb
DeveelDB is a complete SQL database system, primarly developed for .NET/Mono frameworks
Stars: ✭ 80 (+158.06%)
Mutual labels:  sql-query
gpx-converter
python package for manipulating gpx files and easily converting gpx to other different formats
Stars: ✭ 54 (+74.19%)
Mutual labels:  csv-converter
Join Monster
A GraphQL to SQL query execution layer for query planning and batch data fetching.
Stars: ✭ 2,395 (+7625.81%)
Mutual labels:  sql-query
brain-brew
Automated Anki flashcard creation and extraction to/from Csv
Stars: ✭ 55 (+77.42%)
Mutual labels:  csv-converter
Sqlbuilder
A powerful, fast, cross-platform SQL Builder for PHP. Convert your structured data into SQL queries with a fluent style interface and targeting on all the mainstream database (MySQL, PostgreSQL, SQLite)
Stars: ✭ 131 (+322.58%)
Mutual labels:  sql-query
Querybuilder
SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
Stars: ✭ 2,111 (+6709.68%)
Mutual labels:  sql-query
ip2location-csv-converter
This PHP script converts IP2Location CSV database into IP range or CIDR format.
Stars: ✭ 26 (-16.13%)
Mutual labels:  csv-converter
Tableqa
AI Tool for querying natural language on tabular data.
Stars: ✭ 109 (+251.61%)
Mutual labels:  sql-query
SQL-Practice
Solutions to Problems For SQL on Leetcode, Hackerrank & DataLemur
Stars: ✭ 116 (+274.19%)
Mutual labels:  sql-query
Minisqlquery
Minimalist SQL Query tool for any .NET DB Provider - SQL, SQLite, SQL CE, Oracle, Access...
Stars: ✭ 103 (+232.26%)
Mutual labels:  sql-query
Database
💾 A database layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.
Stars: ✭ 251 (+709.68%)
Mutual labels:  sql-query
NLIDB
Natural Language Interface to DataBases
Stars: ✭ 100 (+222.58%)
Mutual labels:  sql-query
AndroidEasySQL-Library
An Easier & Lazier approach to SQL database for Android
Stars: ✭ 28 (-9.68%)
Mutual labels:  sql-query
CSV2RDF
Streaming, transforming, SPARQL-based CSV to RDF converter. Apache license.
Stars: ✭ 48 (+54.84%)
Mutual labels:  csv-converter

qhs CI Status

SQL queries on CSV and TSV files

This is a Haskell implementation of q command.

Installation

Homebrew

 $ brew install itchyny/tap/qhs

Build with stack

Prepare stack command from here.

 $ git clone https://github.com/itchyny/qhs
 $ cd qhs
 $ stack install
 $ export PATH=$PATH:$HOME/.local/bin
 $ qhs "SELECT 100+200"
300

Usage

In the beginning, qhs [QUERY] is the basic usage.

 $ wc * > wc_out.txt
 $ qhs "SELECT * FROM ./wc_out.txt"
66 471 3131 File.hs
118 649 4962 Main.hs
61 258 2346 Option.hs
51 366 2564 Parser.hs
45 273 1769 SQL.hs
341 2017 14772 total

You can specify the file name for the table name. The column names are automatically assigned as c1, c2 and so on.

 $ qhs "SELECT c4,c1 FROM ./wc_out.txt WHERE c4 <> 'total' ORDER BY c1 DESC"
Main.hs 118
File.hs 66
Option.hs 61
Parser.hs 51
SQL.hs 45

The qhs command can read the table from the standard input as well.

 $ wc * | qhs "SELECT c4,c1 FROM - WHERE c4 <> 'total' ORDER BY c1 DESC"
Main.hs 118
File.hs 66
Option.hs 61
Parser.hs 51
SQL.hs 45

You can use -H flag to make qhs regard the head line as the row of column names.

 $ cat basic.csv
foo,bar,baz
a0,1,a2
b0,3,b2
c0,,c2
 $ qhs -H "SELECT * FROM basic.csv WHERE bar IS NOT NULL"
a0 1 a2
b0 3 b2

You can use the basic SQL operations; GROUP BY, ORDER BY, LIMIT and COUNT(*).

 $ ps -ef | qhs -H -O "SELECT UID,COUNT(*) cnt FROM - GROUP BY UID ORDER BY cnt DESC LIMIT 3"
UID cnt
503 102
0 86
89 3

You can also use other SQL operations like JOIN, UNION and sub-query. The command helps you deal with multiple CSV files.

Please refer to qhs --help for further options. The command respects the behaviour of the original q command.

 $ qhs --help
qhs - SQL queries on CSV and TSV files

Usage: qhs [-H|--skip-header] [-O|--output-header] [-d|--delimiter DELIMITER]
           [-t|--tab-delimited] [-D|--output-delimiter OUTPUT_DELIMITER]
           [-T|--tab-delimited-output] [-k|--keep-leading-whitespace]
           [-z|--gzipped] [-q|--query-filename QUERY_FILENAME] [QUERY]

Available options:
  -h,--help                Show this help text
  -v,--version             Show the version of the command.
  -H,--skip-header         Skip the header row for row input and use it for
                           column names instead.
  -O,--output-header       Output the header line.
  -d,--delimiter DELIMITER Field delimiter. If not specified, automatically
                           detected.
  -t,--tab-delimited       Same as -d $'\t'.
  -D,--output-delimiter OUTPUT_DELIMITER
                           Field delimiter for output. If not specified, the
                           argument of -d DELIMITER is used.
  -T,--tab-delimited-output
                           Same as -D $'\t'.
  -k,--keep-leading-whitespace
                           Keep leading whitespace in values. The leading
                           whitespaces are stripped off by default.
  -z,--gzipped             Assuming the gzipped input.
  -q,--query-filename QUERY_FILENAME
                           Read query from the provided filename.

Author

itchyny (https://github.com/itchyny)

License

This software is released under the MIT License, see LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].