Package: preql-lang
Preql 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:PostgresMySQLSqliteBigQuery (WIP)More... (planned)For features that are database-specific, or aren't implemented in Preql, there is aSQL()function that provides a convenient escape hatch to write raw SQL code.Main FeaturesModern syntax and semanticsInterpreted, everything is an objectStrong type system with gradual type validation and duck-typingCompiles to SQLPython and Pandas integrationInteractive shell (REPL) with auto-completionRuns on Jupyter NotebookNote: Preql is still work in progress, and isn't ready for production use, or any serious use quite yet.Learn MoreRead the documentationFollow the tutorialBrowse the examplesCheck out the online demo:Get startedSimply install via pip:pipinstall-Upreql-langThen just run the interpreter:preqlRequires Python 3.6+Read moreQuick Example// Declare a new tabletableContinent{name:stringarea:int// km²population:int}// Initialize the table, by inserting rowsnewContinent("Africa",30370000,1287920000)newContinent("Antarctica",14000000,4490)newContinent("Asia",44579000,4545133000)newContinent("Europe",10180000,742648000)newContinent("North America",24709000,587615000)newContinent("South America",17840000,428240000)newContinent("Australia",8600000,41261000)// Print the continents, ordered by densityprintContinent{...// Include existing fieldsdensity:population/area// Create new a field}order{^density}// Print the total land areaprint"Total land area:",sum(Continent{area}),"km²"//  ========================= Output ==========================table=7┏━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓┃id┃name┃area┃population┃density┃┡━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩│3│Asia│44579000│4545133000│101.9568182328002││4│Europe│10180000│742648000│72.9516699410609││1│Africa│30370000│1287920000│42.40763911755021││6│SouthAmerica│17840000│428240000│24.004484304932735││5│NorthAmerica│24709000│587615000│23.781415678497712││7│Australia│8600000│41261000│4.797790697674419││2│Antarctica│14000000│4490│0.0003207142857142857│└────┴───────────────┴──────────┴────────────┴───────────────────────┘Totallandarea:150278000km²In the background, this table was generated by executing the following compiled SQL code (reformatted):-- Continent {..., density: population / area} order{ ^density }WITHsubq_1(id,name,area,population,density)AS(SELECTid,name,area,population,(CAST(populationASfloat)/area)ASdensityFROMContinentORDERBYdensityDESC)SELECT*FROMsubq_1See more examples inthe examples folder.Interactive EnvironmentLicensePreql uses an “Interface-Protection Clause” on top of the MIT license.See:LICENSEIn 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