Introduction
QueryScript is a strongly typed programming language that builds on SQL. It provides modern tooling, modularity, and integrations with popular relational databases. QueryScript is built for application business logic, transformations, ETL, and visualization.
- SQL and more. Queryscript is a powerful programming language with variables, functions, and modules. SQL is a first class concept in the language.
- Write once, run anywhere. QueryScript typechecks your data model and queries, ensuring your code will run against any database backend without porting.
- Performance always. QueryScript is built in Rust and can run natively in your Typescript and Python apps. It pushes down as much compute as possible into the underlying relational database.

Quickstart
Learn how to install and use QueryScript
Demo (coming soon!)
Try out QueryScript in your browser
Example
Here's a quick example of QueryScript:
-- Variables (including relations) are namespaced and can be imported. The below queries will
-- work for any definition of `users` and `events` as long as they typecheck.
import users, events from schema;
-- You can define variables (including scalars and relations)
-- using `let <name> [<type>] = <expr>`. These expressions are
-- lazily evaluated (and potentially inlined), so there is no
-- cost to defining them.
let active_users = SELECT * FROM users WHERE active;
-- You can run queries inline to help with debugging
SELECT COUNT(*) FROM active_users;
-- You can define functions that operate over values. Just like
-- variables, functions can be inlined and pushed down into the
-- target database, or evaluated directly.
fn username(user_id bigint) {
SELECT name FROM active_users WHERE id = user_id
}
-- Find the users with the most events
SELECT username(user_id), COUNT(*) FROM events GROUP BY 1 ORDER BY 2 DESC LIMIT 10;
-- Find the users who are at risk of churn
SELECT username(user_id), MAX(ts) FROM events GROUP BY 1 HAVING MAX(ts) < NOW() - INTERVAL 1 MONTH;
-- You can also define functions over relations
fn most_popular_events(events) {
SELECT name, COUNT(*) num FROM events ORDER BY 2 DESC
}
-- And see the most popular events globally
most_popular_events(events);
-- Or per user (this will return a sorted array of events
-- for each user)
SELECT username(user_id), most_popular_events(e) FROM events e GROUP BY 1;