# PRQL — Pipelined Relational Query Language > A modern language that compiles to SQL, designed for data transformations with a readable pipeline syntax. ## Install Save as a script file and run: # PRQL — Pipelined Relational Query Language ## Quick Use ```bash pip install prqlc # Or install via cargo cargo install prqlc # Compile PRQL to SQL echo "from employees | filter age > 30 | select {name, age}" | prqlc compile ``` ## Introduction PRQL (pronounced "prequel") is a modern query language that compiles to SQL. It was created to address the readability and composability limitations of SQL by introducing a pipelined, functional syntax that makes data transformations more intuitive and maintainable. ## What PRQL Does - Compiles a readable pipeline syntax into standard SQL for any database - Supports variables, functions, and modular query composition - Provides a type system that catches errors before queries reach the database - Integrates with Python, JavaScript, Rust, and other languages via bindings - Offers editor extensions with syntax highlighting and live SQL preview ## Architecture Overview PRQL is built as a compiler in Rust. Source code passes through a lexer, parser, semantic analyzer, and finally a SQL backend that emits dialect-specific output. The compiler is packaged as a CLI tool (prqlc), a Rust library, and WASM bindings that power integrations for Python (prqlc-python), JavaScript, and database tools like DBeaver and Jupyter. ## Self-Hosting & Configuration - Install the CLI via pip, cargo, brew, or npm depending on your ecosystem - Use prqlc compile to convert .prql files to .sql as part of your CI pipeline - Integrate with dbt via the dbt-prql plugin for transformation workflows - Configure target SQL dialect (PostgreSQL, MySQL, SQLite, BigQuery, etc.) with the --target flag - Embed in Jupyter notebooks using the %%prql magic command from pyprql ## Key Features - Pipeline syntax reads top-to-bottom like data actually flows - S-strings allow raw SQL escape hatches when needed - Automatic column tracking eliminates repetitive GROUP BY clauses - Dialect-aware compilation targets 15+ SQL databases - Composable functions let you build reusable query libraries ## Comparison with Similar Tools - **SQL** — PRQL compiles to SQL; it is not a replacement but a more ergonomic authoring layer - **Malloy** — Malloy is a semantic modeling language; PRQL focuses on ad-hoc query composition - **dbt** — dbt orchestrates SQL transformations; PRQL can be used inside dbt via a plugin - **LINQ** — LINQ is embedded in .NET languages; PRQL is language-agnostic with multi-platform bindings - **Kusto (KQL)** — KQL is Azure-specific; PRQL targets any SQL database ## FAQ **Q: Can I use PRQL with my existing database?** A: Yes. PRQL compiles to standard SQL, so it works with PostgreSQL, MySQL, SQLite, BigQuery, ClickHouse, DuckDB, and many others. **Q: Does PRQL support joins?** A: Yes. PRQL supports join operations with a cleaner syntax than SQL, including automatic column disambiguation. **Q: Is PRQL production-ready?** A: PRQL is at version 0.x but is actively used in production data pipelines. The compiler is well-tested with thousands of test cases. **Q: Can I mix PRQL and raw SQL?** A: Yes. S-strings let you embed raw SQL expressions anywhere in a PRQL query for cases the language does not yet cover. ## Sources - https://github.com/PRQL/prql - https://prql-lang.org --- Source: https://tokrepo.com/en/workflows/asset-4fe82100 Author: Script Depot