Skip to main content

Python extensions for PRQL

Project description

pyprql

CI/CD Documentation Status

PyPI PyPI - Python Version Codestyle: Black

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's compile function

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.

Project details


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.13.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyprql-0.13.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file pyprql-0.13.0.tar.gz.

File metadata

  • Download URL: pyprql-0.13.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyprql-0.13.0.tar.gz
Algorithm Hash digest
SHA256 ce248b06888b566bf517aebf3a371cf4f3db051863951f3ae513f63b9582ac73
MD5 0920ed460c495d42a8a7f518e8deeb83
BLAKE2b-256 7a952e62878cbd02e25149ddd3b891c66a95762bee44669e4d92e4ae3c0c66bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyprql-0.13.0.tar.gz:

Publisher: release.yaml on PRQL/pyprql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyprql-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: pyprql-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyprql-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f0df8abca05ce15717dd6ac7e3e9f9a41d9be67d881f1fe553a7ad3650919e2
MD5 eabb611ab8cb0fb6e01accd4ed3b69ef
BLAKE2b-256 32cf534c75c7b34185f244d3dface594009cc9490cbfc1ef61ad80a83428e315

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyprql-0.13.0-py3-none-any.whl:

Publisher: release.yaml on PRQL/pyprql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page