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.9.0.tar.gz
(16.7 kB
view details)
Built Distribution
pyprql-0.9.0-py3-none-any.whl
(19.1 kB
view details)
File details
Details for the file pyprql-0.9.0.tar.gz
.
File metadata
- Download URL: pyprql-0.9.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a77bd67920ca8fec3e637b24af58b03ba484b0be1bd82028900a331ea021993c |
|
MD5 | 820139554c78b409904bfa1184200394 |
|
BLAKE2b-256 | d0f885d43a7c46dc8987033fe7274ceaf4399d28160769c4179c5391efd7372c |
Provenance
File details
Details for the file pyprql-0.9.0-py3-none-any.whl
.
File metadata
- Download URL: pyprql-0.9.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7161534fd3abbeb96368fd31a5cdb2501e30c4f27fd98c8364bd56eff3799a4f |
|
MD5 | 154f792ed643d98938723c2849cc7254 |
|
BLAKE2b-256 | 3a5929c4b5f7a21bf82ddf79ad148a4f961c94257d67bec030d7641004a57e6d |