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.magic — IPython magic for connecting to databases using %%prql
  • pyprql.compile — An export of prql-python's compile 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


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

Uploaded Source

Built Distribution

pyprql-0.7.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyprql-0.7.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.15 tqdm/4.65.0 importlib-metadata/6.1.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.6

File hashes

Hashes for pyprql-0.7.0.tar.gz
Algorithm Hash digest
SHA256 9d319d39aad5589e98aa08d59ca15e519b76e82fb545839df2619611044fa45c
MD5 f3736e04e1a7075ee44a46a1a972de8f
BLAKE2b-256 1d5fd0d9e2357fa958e397f766c05f8d22d06c4a27a2aece3bdb459b853667ce

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pyprql-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.15 tqdm/4.65.0 importlib-metadata/6.1.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.6

File hashes

Hashes for pyprql-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22f13109e8f9cc6c9528da390a411a804ea531c8a91c024c9c0a20da091d37b4
MD5 cb44914a4fe0076a00e3b6af491fb98a
BLAKE2b-256 49de84f0dddda86a8373ea1eea42a6d36f104f349a3efbd89bfdf6ad3a81db88

See more details on using hashes here.

Provenance

Supported by

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