2
2
3
3
## Installation
4
4
5
- ` prqlc ` can be installed with ` cargo ` :
5
+ ` prqlc ` is a single, dependency-free binary that compiles PRQL into SQL.
6
+ precompiled binaries are available for Linux, macOS, and Windows on the
7
+ [ PRQL release page] ( https://github.com/PRQL/prql/releases ) .
8
+
9
+ ` prqlc ` can be installed via ` cargo ` :
6
10
7
11
``` sh
12
+ # From crates.io
8
13
cargo install prqlc
9
14
```
10
15
11
- ...or built from source:
12
-
13
16
``` sh
17
+ # From a local PRQL repository
14
18
cargo install --path prql-compiler/prqlc
15
19
```
16
20
@@ -22,6 +26,10 @@ brew install prql/prql/prql-compiler
22
26
23
27
## Usage
24
28
29
+ ### prqlc compile
30
+
31
+ This command is working as a filter to compile PRQL string into SQL string.
32
+
25
33
``` sh
26
34
$ echo " from employees | filter has_dog | select salary" | prqlc compile
27
35
32
40
WHERE
33
41
has_dog
34
42
```
43
+
44
+ PRQL query can be executed with CLI tools working with SQL, such as
45
+ [ DuckDB CLI] ( https://duckdb.org/docs/api/cli.html ) .
46
+
47
+ ``` sh
48
+ $ curl -sL https://raw.githubusercontent.com/PRQL/prql/0.8.1/prql-compiler/tests/integration/data/chinook/albums.csv -o albums.csv
49
+ $ echo " from ` albums.csv` | take 3" | prqlc compile | duckdb
50
+ ┌──────────┬───────────────────────────────────────┬───────────┐
51
+ │ album_id │ title │ artist_id │
52
+ │ int64 │ varchar │ int64 │
53
+ ├──────────┼───────────────────────────────────────┼───────────┤
54
+ │ 1 │ For Those About To Rock We Salute You │ 1 │
55
+ │ 2 │ Balls to the Wall │ 2 │
56
+ │ 3 │ Restless and Wild │ 2 │
57
+ └──────────┴───────────────────────────────────────┴───────────┘
58
+ ```
59
+
60
+ Executing this command without any argument will start interactive mode,
61
+ allowing you to write PRQL query interactively. In this mode, after you write
62
+ PRQL and press ` Ctrl-D ` (Linux, macOS) or ` Ctrl-Z ` (Windows) to display the
63
+ compiled SQL.
64
+
65
+ ``` sh
66
+ $ prqlc compile
67
+ ```
68
+
69
+ As with using it as a filter, you can pass the SQL string output to the DuckDB
70
+ CLI, etc.
71
+
72
+ ``` sh
73
+ $ prqlc compile | duckdb
74
+ from ` albums.csv`
75
+ take 3
76
+
77
+ ┌──────────┬───────────────────────────────────────┬───────────┐
78
+ │ album_id │ title │ artist_id │
79
+ │ int64 │ varchar │ int64 │
80
+ ├──────────┼───────────────────────────────────────┼───────────┤
81
+ │ 1 │ For Those About To Rock We Salute You │ 1 │
82
+ │ 2 │ Balls to the Wall │ 2 │
83
+ │ 3 │ Restless and Wild │ 2 │
84
+ └──────────┴───────────────────────────────────────┴───────────┘
85
+ ```
0 commit comments