Pyprql
Python extensions for PRQL
Install / Use
/learn @PRQL/PyprqlREADME
pyprql
<!-- [](https://codecov.io/gh/prql/PyPrql) -->pyprql contains:
- pyprql.pandas_accessor — Pandas integration for PRQL
- pyprql.polars_namespace — Polars integration for PRQL
- pyprql.magic — IPython magic for connecting to databases using
%%prql - pyprql.compile — An export of
prqlc'scompilefunction
For docs, check out the pyprql docs, and the PRQL Book.
Installation
pip install pyprql
Or, install with optional dependencies:
pip install pyprql[polars]
Usage
Pandas integration
import pandas as pd
import pyprql.pandas_accessor
df = (...)
results_df = df.prql.query("select {age, name, occupation} | filter age > 21")
Polars integration
import polars as pl
import pyprql.polars_namespace
df = (...)
results_df = df.prql.query("select {age, name, occupation} | filter age > 21")
Jupyter Magic
In [1]: %load_ext pyprql.magic
In [2]: %prql postgresql://user:password@localhost:5432/database
In [3]: %%prql
...: from p
...: group categoryID (
...: aggregate {average unitPrice}
...: )
In [4]: %%prql results <<
...: from p
...: aggregate {min unitsInStock, max unitsInStock}
Compilation
This library exposes prqlc.compile, so we can simply generate SQL:
import pyprql
pyprql.compile("from artists | select track")
print(pyprql.compile("from artists | select track"))
...returns...
SELECT
track
FROM
artists
For context, prqlc in Python is the Python binding for the prqlc Rust crate, so only
contains functions for compilation; and this library offers broader python
integrations and tooling.
Support
This project was created by @charlie-sanders & @rbpatt2019 and is now maintained by the broader PRQL team.
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
