Skip to content

Commit

Permalink
Add missing cargo pgrx init step to installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspermarstal committed Jan 13, 2024
1 parent f069179 commit 7fa55c2
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,44 @@ For more information on the design of the extension, see the [design document](D
For more information on PRQL, visit the PRQL [website](https://prql-lang.org/), [repository](https://github.com/PRQL/prql), or [playground](https://prql-lang.org/playground/).

# Intended Use
PRQL shines when your SQL queries becomes very long and complex. To convince yourself, take a look at examples on the [PRQL playground](https://prql-lang.org/playground/). You can manage this complexity by porting your most impressive SQL queries to PRQL functions, which can then be used in business logic or other database code. The majority of your database code typically will continue to live in vanilla SQL, ORMs, or other database frameworks.
PRQL shines when your SQL queries becomes very long and complex. You can manage this complexity by porting your most impressive SQL queries to PRQL functions, which can then be used in business logic or other database code.

> [!NOTE]
>
> PRQL supports `select` statements only. The majority of your database code, including `insert`, `update`, and `delete` statements, will typically continue to live in vanilla SQL, ORMs, or other database frameworks.
# Getting started
Follow these steps to install PL/PRQL from source:
On Ubuntu, follow these steps to install PL/PRQL from source:

1. Install `cargo-pgrx`.

```cmd
cargo install --locked cargo-pgrx
cargo install --locked --version=0.11.2 cargo-pgrx
```
The version of `cargo-pgrx` must match the version of `pgrx` in `Cargo.toml`.
2. Clone this repository and `cd` into root directory.
2. Initialize `pgrx` for your system.
```cmd
cargo pgrx init --pg16 <PG16>
```
where `<PG16>` is the path to your system installation's `pg_config` tool (typically `/usr/bin/pg_config`). Supported versions are PostgreSQL v12-16. You can also run `cargo pgrx init` and have `pgrx` download, install, and compile PostgreSQL v12-16. These installations are managed by `pgrx` and used for development and testing. Individual `pgrx` installations can be installed using e.g. `cargo pgrx init --pg16 download`.

3. Clone this repository and `cd` into root directory.

```cmd
git clone https://github.com/kaspermarstal/plprql
cd plprql
```
3. Install the extension to the PostgreSQL specified by
4. Install the extension to the PostgreSQL specified by
the `pg_config` currently on your `$PATH`.
```cmd
cargo pgrx install --release
```
You can target a specific PostgreSQL installation by providing the path of another `pg_config` using the `-c` flag.

4. Fire up PostgreSQL and start writing functions right away!
5. Fire up PostgreSQL and start writing functions right away!
```cmd
$ cargo pgrx run pg16
psql> create extension plprql;
Expand All @@ -66,20 +76,14 @@ Follow these steps to install PL/PRQL from source:
```

## Running Tests
Run the `init` command:

```cmd
cargo pgrx init
```

The `init` command downloads, compiles, and installs PostgreSQL v12-16 which are used for testing. You can now run tests using `cargo pgrx test`. To run tests for all supported versions of PostgreSQL, run
You can now run tests using `cargo pgrx test`. To run tests for all supported versions of PostgreSQL, run

```cmd
cargo pgrx test pg12
cargo pgrx test pg13
cargo pgrx test pg14
cargo pgrx test pg15
cargo pgrx test pg16
cargo pgrx test pg15
cargo pgrx test pg14
cargo pgrx test pg13
cargo pgrx test pg12
```

# License
Expand Down

0 comments on commit 7fa55c2

Please sign in to comment.