Jupyter

pyprql contains pyprql.magic, a thin wrapper of JupySQL’s SQL IPython magics. This allows us to run PRQL interactively on Jupyter/IPython.

Check out https://pyprql.readthedocs.io/ for more context.

Installation

  1. pip install pyprql

Usage

When installing pyprql, the duckdb-engine package is also installed with it, so we can start using PRQL immediately to query CSV and Parquet files.

For example, running the example from the JupySQL documentation on IPython:

  1. In [1]: %load_ext pyprql.magic
  2. In [2]: !curl -sL https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv -o penguins.csv
  3. In [3]: %prql duckdb://
  4. In [4]: %prql from `penguins.csv` | take 3
  5. Out[4]:
  6. species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
  7. 0 Adelie Torgersen 39.1 18.7 181 3750 MALE
  8. 1 Adelie Torgersen 39.5 17.4 186 3800 FEMALE
  9. 2 Adelie Torgersen 40.3 18.0 195 3250 FEMALE
  10. In [5]: %%prql
  11. ...: from `penguins.csv`
  12. ...: filter bill_length_mm > 40
  13. ...: take 3
  14. ...:
  15. ...:
  16. Out[5]:
  17. species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
  18. 0 Adelie Torgersen 40.3 18.0 195 3250 FEMALE
  19. 1 Adelie Torgersen 42.0 20.2 190 4250 None
  20. 2 Adelie Torgersen 41.1 17.6 182 3200 FEMALE