Skip to content

TypeSQL vs Reylo ​

Reylo lets TypeScript import .sql files and types them from a live database. Like TypeSQL, it has no generated files and needs TypeScript 7.1: it runs as a content mapper that the compiler calls for each .sql import. To type a query, it prepares the statement on your development database (PostgreSQL, MySQL) or reads the database file (SQLite).

The same query ​

With Reylo, in recent_posts.sql:

sql
select u.id, u.email, p.title
from users u
left join posts p on p.author_id = u.id
where u.created_at > :since
ts
import recentPosts from "./recent_posts.sql";

const rows = await recentPosts.run(db, { since: new Date("2026-01-01") });

With TypeSQL, the SQL stays next to the code that runs it:

ts
const rows = await sql(
	`select u.id, u.email, p.title
   from users u
   left join posts p on p.author_id = u.id
   where u.created_at > ${sql.param(new Date("2026-01-01"))}`,
).execute();

How they differ ​

ReyloTypeSQL
You writeSQL in .sql files, imported from TypeScriptSQL strings in TypeScript
Types come froma live development database, through a content mapperthe TypeScript compiler, reading your schema type
Type checking needsa running database, and tsc --runExternalCodetsc
Running queriesa preload (--import reylo/register) or bundler plugin, with the engine installed at runtimesql() builds { text, values }, and your driver sends it
Dynamic queriesCASE on parameters, and JSON parameters described by a JSON Schemafragments
Migrationsapplied with your own toolapplied with your own tool, or written as DDL that the schema type follows
DatabasesPostgreSQL, MySQL, SQLite, DuckDB (preview)PostgreSQL and SQLite; MySQL is planned

Both work out nullability from outer joins and from WHERE conditions that reject NULL.

Choose Reylo when ​

  • You use MySQL or DuckDB.
  • You want your SQL in .sql files.
  • You want database errors typed, with .try() returning { value } or { error }.
  • You'd rather check queries against the real database than keep a schema type in sync with it.

Choose TypeSQL when ​

  • You want SQL next to the code that runs it, not in a separate file.
  • You want to type-check in the editor and CI without a database running.
  • You don't want a preload or bundler plugin to run your app, or the engine installed in production.
  • Some queries are built from pieces at runtime.