Python extensions for PRQL
Project description
pyprql
pyprql contains:
- pyprql.pandas_accessor — Pandas integration for PRQL
- pyprql.magic — IPython magic for connecting to databases using
%%prql
- pyprql.compile — An export of
prql-python
'scompile
function
For docs, check out the pyprql docs, and the PRQL Book.
Installation
pip install pyprql
Usage
Pandas integration
import pandas as pd
import pyprql.pandas_accessor
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 prql-python.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, prql-python
is the Python binding for prql-compiler
, 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyprql-0.10.0.tar.gz
(17.5 kB
view details)
Built Distribution
pyprql-0.10.0-py3-none-any.whl
(19.8 kB
view details)
File details
Details for the file pyprql-0.10.0.tar.gz
.
File metadata
- Download URL: pyprql-0.10.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e0d393e90d0d62daf749ddb098ffd6552b8ee34dd4b79724e6884e4335d3aaa |
|
MD5 | 9a7095807b5a64f880ea023d4d9aee03 |
|
BLAKE2b-256 | 9fd64b4c617e33e5ff1b94b21fc145f59effc148fb69f91361c4b52996607044 |
Provenance
File details
Details for the file pyprql-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: pyprql-0.10.0-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b67238d5ac51736b09f6797daeaf5fc0f0fae651afe9f67b0e24e21d15675515 |
|
MD5 | 1176978f0e4f15a8c1503e66e37d83c1 |
|
BLAKE2b-256 | 088e2c21238689cd4e32f1e1b37e337bdca89b58c5553ddbcb2aeddf5b9a2029 |