An interpreted relational query language that compiles to SQL
Project description
Preql (pronounced: Prequel) is an interpreted relational query language.
It is designed for use by data engineers, analyists and data scientists.
-
Compiles to SQL at runtime. It has the performance and abilities of SQL, and much more.
-
Support for Postgres, MySQL and Sqlite. (more planned!)
-
Escape hatch to SQL, for all those databse-specific features we didn't think to include
-
-
Programmer-friendly syntax and semantics, with gradual type-checking, inspired by Typescript and Python
-
Interface through Python, HTTP or a terminal environment with autocompletion
Note: Preql is still work in progress, and isn't ready for production use, or any serious use yet
Documentation
Get started
Simply install via pip:
pip install -U prql
Then just run the interpeter:
preql
Requires Python 3.8+
Quick Example
// Sum up all the squares of an aggregated list of numbers
// Grouped by whether they are odd or even
func sqrsum(x) = sum(x * x)
func is_even(x) = x % 2 == 0
print [1..100]{
is_even(item) => sqrsum(item)
}
// Result is:
┏━━━━━━━━━┳━━━━━━━━┓
┃ is_even ┃ sqrsum ┃
┡━━━━━━━━━╇━━━━━━━━┩
│ 0 │ 166650 │
│ 1 │ 161700 │
└─────────┴────────┘
In the background, this was run by executing the following SQL code (reformatted):
WITH range1 AS (SELECT 1 AS item UNION ALL SELECT item+1 FROM range1 WHERE item+1<100)
, subq_3(is_even, sqrsum) AS (SELECT ((item % 2) = 0) AS is_even, SUM(item * item) AS sqrsum FROM range1 GROUP BY 1)
SELECT * FROM subq_3
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.
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
Built Distribution
File details
Details for the file prequel-0.1.8.tar.gz
.
File metadata
- Download URL: prequel-0.1.8.tar.gz
- Upload date:
- Size: 65.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.2 CPython/3.8.2 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c25fb09b802e0e101252ca1bcb1c0026ca888de5ea26b2fb8bc5fa54d329ce7a |
|
MD5 | 5d498df52ebc0e21043cd1dff5bdd035 |
|
BLAKE2b-256 | 44a8d1b003de115476d35e477af2c03cae324847fdb983a259cb82e2f5c35640 |
File details
Details for the file prequel-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: prequel-0.1.8-py3-none-any.whl
- Upload date:
- Size: 74.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.2 CPython/3.8.2 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9abdfe2f7b5955aba1881dbd0fa9730f06788bf4327a6a6612ce904c84c7a03 |
|
MD5 | 68e984b3c8965b2ffd59acc4445c4673 |
|
BLAKE2b-256 | 07687c041983d4169c98429a2d36547d8066daa25fbca34fa2d07bd3be58bad1 |