{"id":16937359,"url":"https://github.com/erezsh/preql","last_synced_at":"2025-05-16T14:05:22.356Z","repository":{"id":38832198,"uuid":"161368655","full_name":"erezsh/Preql","owner":"erezsh","description":"An interpreted relational query language that compiles to SQL.","archived":false,"fork":false,"pushed_at":"2022-08-17T08:31:24.000Z","size":1553,"stargazers_count":620,"open_issues_count":18,"forks_count":12,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-16T14:05:21.970Z","etag":null,"topics":["data-science","database","python","query","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erezsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-11T17:18:32.000Z","updated_at":"2025-05-12T18:40:45.000Z","dependencies_parsed_at":"2022-07-08T19:50:17.838Z","dependency_job_id":null,"html_url":"https://github.com/erezsh/Preql","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erezsh%2FPreql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erezsh%2FPreql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erezsh%2FPreql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erezsh%2FPreql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erezsh","download_url":"https://codeload.github.com/erezsh/Preql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","database","python","query","sql"],"created_at":"2024-10-13T20:59:23.335Z","updated_at":"2025-05-16T14:05:22.333Z","avatar_url":"https://github.com/erezsh.png","language":"Python","readme":"![alt text](logo_small.png \"Logo\")\n\nPreql is an interpreted, relational programming language, that specializes in database queries.\n\nIt is designed for use by data engineers, analysts and data scientists.\n\nPreql'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.\n\n**How does it work?**\n\nPreql 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.\n\nCurrently supported dialects are:\n* Postgres\n* MySQL\n* Sqlite\n* BigQuery\n* More... (planned)\n\nFor 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.\n\n**Main Features**\n\n* Modern syntax and semantics\n    - Interpreted, everything is an object\n    - Strong type system with gradual type validation and duck-typing\n* Compiles to SQL\n* Python and Pandas integration\n* Interactive shell (REPL) with auto-completion\n* Runs on Jupyter Notebook\n\n\n**Note: Preql is still work in progress, and isn't yet recommended for use in production.**\n\n[![tests](https://github.com/erezsh/preql/actions/workflows/tests.yml/badge.svg)](https://github.com/erezsh/Preql/actions/workflows/tests.yml)\n\n# Learn More\n\n- [**Read the documentation**](https://preql.readthedocs.io/en/latest/)\n\n- [Follow the tutorial](https://preql.readthedocs.io/en/latest/tutorial.html)\n\n- [Browse the examples](https://github.com/erezsh/Preql/tree/master/examples)\n\n- Check out the online demo: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/erezsh/preql-binder/master?filepath=tutorial_exploring_a_database.ipynb)\n\n# Get started\n\nSimply install via pip:\n\n```sh\n    pip install -U preql\n```\n\nThen just run the interpreter:\n\n```sh\n    preql\n```\n\nRequires Python 3.6+\n\n[Read more](https://preql.readthedocs.io/en/latest/getting-started.html)\n\n# Quick Example\n\n```javascript\n// Declare a new table\ntable Continent {\n    name: string\n    area: int       // km²\n    population: int\n}\n\n// Initialize the table, by inserting rows\nnew Continent(\"Africa\", 30370000, 1287920000)\nnew Continent(\"Antarctica\", 14000000, 4490)\nnew Continent(\"Asia\", 44579000, 4545133000)\nnew Continent(\"Europe\", 10180000, 742648000)\nnew Continent(\"North America\", 24709000, 587615000)\nnew Continent(\"South America\", 17840000, 428240000)\nnew Continent(\"Australia\", 8600000, 41261000)\n\n// Print the continents, ordered by density\nprint Continent {\n    ...                         // Include existing fields\n    density: population / area  // Create new a field\n\n} order{^density}\n\n// Print the total land area\nprint \"Total land area:\", sum(Continent{area}), \"km²\"\n\n//  ========================= Output ==========================\n\n                              table  =7\n┏━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓\n┃ id ┃ name          ┃     area ┃ population ┃               density ┃\n┡━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩\n│  3 │ Asia          │ 44579000 │ 4545133000 │     101.9568182328002 │\n│  4 │ Europe        │ 10180000 │  742648000 │      72.9516699410609 │\n│  1 │ Africa        │ 30370000 │ 1287920000 │     42.40763911755021 │\n│  6 │ South America │ 17840000 │  428240000 │    24.004484304932735 │\n│  5 │ North America │ 24709000 │  587615000 │    23.781415678497712 │\n│  7 │ Australia     │  8600000 │   41261000 │     4.797790697674419 │\n│  2 │ Antarctica    │ 14000000 │       4490 │ 0.0003207142857142857 │\n└────┴───────────────┴──────────┴────────────┴───────────────────────┘\n\nTotal land area: 150278000 km²\n```\n\nIn the background, this table was generated by executing the following compiled SQL code (reformatted):\n\n```sql\n-- Continent {..., density: population / area} order{ ^density }\nWITH subq_1(id, name, area, population, density) AS (\n    SELECT id, name, area, population, (CAST(population AS float) / area) AS density\n    FROM Continent\n    ORDER BY density DESC)\nSELECT * FROM subq_1\n```\n\nSee more examples in [the examples folder](https://github.com/erezsh/Preql/tree/master/examples).\n\n# Interactive Environment\n\n![Screenshot.png](docs/screenshot.png)\n\n# License\n\nPreql uses an “Interface-Protection Clause” on top of the MIT license.\n\nSee: [LICENSE](LICENSE)\n\nIn simple words, it's free for personal use. Also, 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. [Read more](https://preql.readthedocs.io/en/latest/faq.html#license)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferezsh%2Fpreql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferezsh%2Fpreql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferezsh%2Fpreql/lists"}