#csv #sql-query #syntax #load #file

app sql_csv

A tool which query csv files use SQL syntax

2 unstable releases

0.2.0 Dec 17, 2021
0.1.0 Dec 15, 2021

#143 in #load

MIT license

12KB
100 lines

CSV SQL Query

A friendly query csv file use sql syntax

Installation

$ cargo install sql_csv

Support Commands

load

Load csv file

load /home/path/to/xxx.csv 

store

Store last success SQL query result to csv file

store /path/to/xxx.csv

SQL

All SQL query support.

select * from user;
select count(*) from user;
select city,count(*) from user group by city;

Examples

$sql_csv.exe c:\temp\user.csv  c:\temp\author.csv
read csv file c:\temp\user.csv to table user
read csv file c:\temp\author.csv to table author
>select * from user;
Result:
+----+-----------+------+---------+
| id | name      | size | sport   |
+----+-----------+------+---------+
| 1  | Xiaoputao | 3    | Hiking  |
| 2  | Zgu       | 3    | Running |
| 3  | Xiaopang  | 2    | Walking |
+----+-----------+------+---------+
>
>load c:\temp\abc.csv
load csv file c:\temp\abc.csv to table abc
Load ok.
>select * from abc;
Result:
+----+-----------+------+---------+
| id | name      | size | sport   |
+----+-----------+------+---------+
| 1  | Xiaoputao | 3    | Hiking  |
| 2  | Zgu       | 3    | Running |
| 3  | Xiaopang  | 2    | Walking |
+----+-----------+------+---------+
>store c:\temp\bar.csv
Store ok.
>

Dependencies

~39MB
~767K SLoC