Skip to main content

Declarative, typed query language that compiles to SQL.

Project description

PreQL

pypreql is a experimental implementation of the preql language [https://github.com/preqldata].

The preql language spec itself will be linked from the above repo.

Pypreql can be run locally to parse and execute preql [.preql] models.

Dialects

The POC supports alpha syntax for

  • SQL Server
  • Bigquery

Setting Up Your Environment

Recommend that you work in a virtual environment with requirements from both requirements.txt and requirements-test.txt installed. The latter is necessary to run tests (surprise).

Pypreql is python 3.9+

Running Tests

The tests are implemented primarily in pytest. To run all tests you are strongly suggested to have docker installed, though you can manually configured the required data warehouse in an express edition of SQL server if docker is not possible. Guidance for the non-docker path is not provided. Docker is STRONGLY RECOMMENDED.

A portion of the tests are dependent on having access to an AdventureWOrks2019DW example database in Microsoft SQL Server that can be downloaded via this [link]https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2019.bak.

The tests will treat this as database server a pytest fixture, starting a docker image if the tests detect a sql server is not already running. Before you run tests you must build this docker image. From the root of this repository run the following to fetch the database data and build a docker image containg it

/bin/bash ./docker/build_image.sh

If you are using windows download the AdventureWorks2019DW database backup from the link above and place it in the ./docker path. From the root of the repo run

docker build --no-cache ./docker/ -t pyreql-test-sqlserver

To run the test suite, from the root of the repository run

python -m pytest ./tests

Developing

import concepts.internet_sales as internet_sales;
import concepts.customer as customer;
import concepts.dates as dates;
import concepts.sales_territory as sales_territory;

select
    customer.first_name,
    customer.last_name,
    internet_sales.total_order_quantity,
    internet_sales.total_sales_amount
order by
    internet_sales.total_sales_amount desc
limit 100;


select
    dates.order_date,
    customer.first_name,
    internet_sales.total_order_quantity,
    internet_sales.total_sales_amount
order by
    internet_sales.total_sales_amount desc
limit 100;


select
    internet_sales.order_number,
    internet_sales.order_line_number,
    internet_sales.total_sales_amount,
    sales_territory.region,
    customer.first_name
order by
    internet_sales.order_number desc
limit 5;
import concepts.internet_sales as internet_sales;
import concepts.customer as customer;
import concepts.dates as dates;
import concepts.sales_territory as sales_territory;

select
    customer.first_name,
    customer.last_name,
    internet_sales.total_order_quantity,
    internet_sales.total_sales_amount
order by
    internet_sales.total_sales_amount desc
limit 100;


select
    dates.order_date,
    customer.first_name,
    internet_sales.total_order_quantity,
    internet_sales.total_sales_amount
order by
    internet_sales.total_sales_amount desc
limit 100;


select
    internet_sales.order_number,
    internet_sales.order_line_number,
    internet_sales.total_sales_amount,
    sales_territory.region,
    customer.first_name
order by
    internet_sales.order_number desc
limit 5;

Contributing

Similar in space

  • singleorigin

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

pypreql-0.0.1rc12.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

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

pypreql-0.0.1rc12-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file pypreql-0.0.1rc12.tar.gz.

File metadata

  • Download URL: pypreql-0.0.1rc12.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for pypreql-0.0.1rc12.tar.gz
Algorithm Hash digest
SHA256 86e967070d5709f39b85d972e69c877978fda29ae65d0ee4dc24c5dc99e23ae8
MD5 8f6849af9a7a099dd75d1f83c8cbede7
BLAKE2b-256 2a36ba4dedf76fdbaff44ccebf990e946574a1ce7faf6c131a8d31d2f7b10762

See more details on using hashes here.

File details

Details for the file pypreql-0.0.1rc12-py3-none-any.whl.

File metadata

  • Download URL: pypreql-0.0.1rc12-py3-none-any.whl
  • Upload date:
  • Size: 36.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for pypreql-0.0.1rc12-py3-none-any.whl
Algorithm Hash digest
SHA256 eb4133dbdc211ce6e05fafb577f6229343bce5d6469518bf5f7e0eefc51bb9c8
MD5 4992b83f5e9604ca29e9817f761438a1
BLAKE2b-256 62241016f3f49c55f38714ffa5577e26926c194926826e1571836dbd044dd469

See more details on using hashes here.

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