A functional, pipeline-style DSL that transpiles to SQL. Write database logic once and run it against PostgreSQL, SQLite, or SQL Server.
Users
|> filter(fn(row) => row.Age > 18 and row.Status = 'active')
|> join(Orders, on = Users.Id = Orders.UserId)
|> select(Users.Name, sum(Orders.Total) as TotalSpent)
|> group_by(Users.Id)
|> order_by(TotalSpent desc)
LQL is database platform independent. The same .lql source must produce semantically identical results on every target dialect.
dotnet new tool-manifest
dotnet tool install Lql --version ${LQL_VERSION}Then transpile during the build:
dotnet Lql sqlite --input GetCustomers.lql --output GetCustomers.generated.sql
dotnet Lql postgres --input GetCustomers.lql --output GetCustomers.generated.sqlReference one of the library packages to transpile LQL in your application code:
dotnet add package Nimblesite.Lql.SQLite --version ${NIMBLESITE_VERSION}
dotnet add package Nimblesite.Lql.Postgres --version ${NIMBLESITE_VERSION}
dotnet add package Nimblesite.Lql.SqlServer --version ${NIMBLESITE_VERSION}using Nimblesite.Lql.Core;
using Nimblesite.Lql.Postgres;
using Nimblesite.Sql.Model;
var lql = """
Customer
|> filter(fn(row) => Customer.Active = true)
|> select(Customer.Id, Customer.Name)
""";
var statement = new LqlStatement(lql);
Result<string, SqlError> result = statement.ToPostgreSql();
var sql = result switch
{
Result<string, SqlError>.Ok ok => ok.Value,
Result<string, SqlError>.Error err =>
throw new InvalidOperationException(err.Value.Message)
};statement.ToSqlite() and statement.ToSqlServer() are also available from their respective packages.
| Project | Description |
|---|---|
Nimblesite.Lql.Core |
Core transpiler library and AST |
Lql |
Unified CLI transpiler tool (subcommands: postgres, sqlite) |
Nimblesite.Lql.Postgres |
ToPostgreSql() extension |
Nimblesite.Lql.SQLite |
ToSqlite() extension |
Nimblesite.Lql.SqlServer |
ToSqlServer() extension |
LqlExtension |
VS Code extension (TypeScript) |
lql-lsp-rust |
Language server (Rust, ANTLR-generated parser) |
Nimblesite.Lql.TypeProvider.FSharp |
F# type provider for compile-time validation |
| Operator | Purpose |
|---|---|
filter(fn(row) => ...) |
WHERE |
select(col1, col2, ...) |
SELECT projection |
join(Table, on = ...) |
INNER JOIN (plus left_join, right_join, full_join) |
group_by(col) |
GROUP BY |
| `order_by(col [asc | desc])` |
limit(n) |
LIMIT / TOP |
distinct() |
DISTINCT |
Aggregates include count, sum, avg, min, max. Parameters are declared with @name.
- LQL language spec: docs/specs/lql-spec.md
- LQL design system: docs/specs/lql-design-system.md
- LSP reference (used by IDE): lql-lsp-rust/crates/lql-reference.md