Skip to main content

alt text

Preql (pronounced: Prequel) is an interpreted, relational programming language, that specializes in database queries.

It is designed for use by data engineers, analysts and data scientists.

Preql's main objective is to provide an alternative to SQL, in the form of a high-level programming language, with first-class functions, modules, strict typing, and Python integration.

How does it work?

Preql code is interpreted and gets compiled to SQL at runtime. This way, Preql gains the performance and abilities of SQL, but can also operate as a normal scripting language.

Currently supported dialects are:

  • Postgres
  • MySQL
  • Sqlite
  • BigQuery (soon)
  • More... (planned)

For features that are database-specific, or aren't implemented in Preql, there is a SQL() function that provides a convenient escape hatch to write raw SQL code.

Main Features

  • Modern syntax and semantics
    • Interpreted, everything is an object
    • Strong type system with gradual type validation and duck-typing
  • Compiles to SQL
  • Python and Pandas integration
  • Interactive shell (REPL) with auto-completion
  • Runs on Jupyter Notebook

Note: Preql is still work in progress, and isn't ready for production use, or any serious use quite yet.

Learn More

Get started

Simply install via pip:

    pip install -U preql-lang

Then just run the interpreter:

    preql

Requires Python 3.8+

Read more

Quick Example

// The following code sums up all the squares of an aggregated list of
// numbers, grouped by whether they are odd or even.

func sum_of_squares(x) = sum(x * x)
func is_even(x) = (x % 2 == 0)

// Create a list of [1, 2, 3, ..., 99]
num_list = [1..100]

// Group by is_even(), and run sum_of_squares() on the grouped values.
print num_list{ is_even(item) => sum_of_squares(item) }

// Result is:
┏━━━━━━━━━┳━━━━━━━━┓
 is_even  sqrsum 
┡━━━━━━━━━╇━━━━━━━━┩
       0  166650 
       1  161700 
└─────────┴────────┘

In the background, this was run by executing the following compiled SQL code (reformatted):

  WITH range1 AS (SELECT 1 AS item UNION ALL SELECT item+1 FROM range1 WHERE item+1<100)
  SELECT ((item % 2) = 0) AS is_even, SUM(item * item) AS sqrsum FROM range1 GROUP BY 1;

License

Preql uses an “Interface-Protection Clause” on top of the MIT license.

See: LICENSE

In simple words, it can be used for any commercial or non-commercial purpose, as long as your product doesn't base its value on exposing the Preql language itself to your users.

If you want to add the Preql language interface as a user-facing part of your commercial product, contact us for a commercial license.

Release files for preql-lang 0.1.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for preql-lang 0.1.17
File Size Uploaded
preql-lang-0.1.17.tar.gz 72.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for preql-lang 0.1.17
File Interpreter ABI Platform
preql_lang-0.1.17-py3-none-any.whl Python 3 none any Details

Total release size: 154.7 kB

Release files / preql-lang-0.1.17.tar.gz

Download URL preql-lang-0.1.17.tar.gz
Size 72.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a11f6b53faac5f5972d8d97af84042396dba3e6d9a0e7a5b19f960950d3e8303
BLAKE2b-256 checksum
How to use checksums
bcda15022bf9b425e73deef892a4309f55153e41d533b695a4f80d3067663446
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.2 CPython/3.8.2 Windows/10

Release files / preql_lang-0.1.17-py3-none-any.whl

Download URL preql_lang-0.1.17-py3-none-any.whl
Size 82.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d62aa28d3d4ff41e6341dd9cd1b1e60908081f90b26766ee78bff955b3d347b
BLAKE2b-256 checksum
How to use checksums
37f4e1cc36e3442df6a7904a86619f6db55202d528163b8fc383e9d6c3b86296
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.2 CPython/3.8.2 Windows/10

Release history Release notifications | RSS feed

0.2.1

2 release files

0.2.0

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

This release

0.1.17 This release

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page