Skip to content

Write SQL.
Get type-safe code.

SQG runs your queries against a real database at build time and generates fully typed access code for TypeScript, Java, and Python. No ORM. No query builder. No runtime overhead.

Write your queries in plain SQL with simple annotations. SQG introspects your database at build time and generates fully typed code.

-- QUERY find_user :one
@set email = '[email protected]'
SELECT * FROM users WHERE email = ${email};

becomes

findUser(email: string): User | undefined

No ORMs. No query builders. Just SQL and types.

Real SQL

Write standard SQL that runs directly against your database. No proprietary query language to learn.

True Type Safety

Types are introspected from your actual schema at build time. Catch errors before production.

Multiple Databases

SQLite, DuckDB, and PostgreSQL. Same annotations work across all engines.

TypeScript, Java & Python

Generate code for multiple languages from the same SQL definitions.

Diagram

Most tools try to parse SQL to figure out types. SQG takes a simpler approach: run the query.

Your migrations set up the schema, SQG executes your queries against a real database, and captures the exact column names and types from the result. No parser limitations, no guessing—100% accurate types.

ORMs SQG
Learn a query builder API Write standard SQL
Types generated from models Types introspected from queries
Hidden SQL, hard to optimize Transparent, debuggable
Runtime query translation No runtime overhead

SQG is for developers who want the safety of typed code without giving up control over their SQL.

Generator Database Language
typescript/sqlite SQLite TypeScript (sync)
typescript/duckdb DuckDB TypeScript (async)
java/sqlite, java/duckdb, java/postgres SQLite, DuckDB, PostgreSQL Java (JDBC)
java/duckdb/arrow DuckDB Java (Arrow API)
python/sqlite, python/duckdb, python/postgres SQLite, DuckDB, PostgreSQL Python

SQG’s @set syntax is compatible with DBeaver, the popular open-source database IDE. Develop and test your queries interactively, then run SQG to generate code.

SQG is open source under the Apache 2.0 license.

GitHub · Issues