Skip to content

Commit

Permalink
docs: Update README.md (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspermarstal authored Dec 26, 2024
1 parent 44da9d4 commit c1ea186
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

# PRQL in PostgreSQL!

PL/PRQL is a PostgreSQL extension that lets you write functions with [PRQL](https://prql-lang.org/). The extension supports PostgreSQL v12-16 on Linux and macOS.
PL/PRQL is a PostgreSQL extension that lets you write stored procedures with [PRQL](https://prql-lang.org/). The extension supports PostgreSQL v12-16 on Linux and macOS.

## What is PRQL?
PRQL (Pipelined Relational Query Language) is an open source query language for data manipulation and analysis that compiles to SQL. PRQL introduces a pipeline concept (similar to Unix pipes) that transforms data line-by-line. The sequential series of transformations reduces the complexity often encountered with nested SQL queries and makes your data manipulation logic easier to read and write.
PRQL (Pipelined Relational Query Language) is an open source query language for data manipulation and analysis that compiles to SQL. PRQL introduces a pipeline concept (similar to Unix pipes) that transforms data line-by-line. The sequential series of transformations reduces the complexity often encountered with nested SQL queries and makes your data manipulation logic easier to read and write. With PL/PRQL you can write Procedural Language (PL) functions (stored procedures) with PRQL instead of the traditional PL/pgSQL and combine the simplicity of PRQL with the power of stored procedures.

## Key features
- [Write functions with PRQL](#functions) - Useful for large analytical queries
- [PRQL compiler](#prql-compiler) - Useful for development and debugging
- [Inline execution](#inline-execution) - Useful for prototyping and custom queries in ORMs
- [Write functions with PRQL](#write-functions-with-prql) - Useful for large analytical queries
- [Compile PRQL queries to SQL queries](#compile-prql-queries-to-sql-queries) - Useful for development and debugging
- [Execute PRQL queries](#execute-prql-queries) - Useful for prototyping and custom queries in ORMs

### Functions
PRQL shines when your SQL queries becomes very long and complex. You can manage this complexity by porting your most impressive SQL incantations to PRQL functions, which can then be used in dashboards, business logic or other database code. For example:
### Write functions with PRQL
PRQL shines when your SQL queries becomes long and complex. You can manage this complexity by porting your most impressive SQL incantations to PRQL functions, which can then be used in dashboards, business logic or other database code. For example:

```sql
create function match_stats(int) returns table(player text, kd_ratio float) as $$
Expand All @@ -40,7 +40,7 @@ select * from match_stats(1001)
(2 rows)
```

### PRQL Compiler
### Compile PRQL queries to SQL queries
You can use `prql_to_sql()` to see the SQL statements that PostgreSQL executes under the hood. This function invokes the PRQL compiler and shows you the resulting SQL code. Using the example above:

```sql
Expand All @@ -61,8 +61,8 @@ WHERE _expr_1 > 0
(1 row)
```

### Inline Execution
You can run PRQL code directly with the `prql` function. This is useful for e.g. custom queries in ORMs:
### Execute PRQL queries
You can run PRQL code directly with the `prql` function. This is useful for e.g. custom queries in application code:

```sql
select prql('from matches | filter player == ''Player1''')
Expand Down

0 comments on commit c1ea186

Please sign in to comment.