DriftSQL is a modern, type-safe SQL client for TypeScript, currently in beta (v2.0.0-beta.6). It provides a built-in schema builder and migration system, allowing developers to define database schemas in code and migrate automatically. Key differentiators include full TypeScript type inference from schema definitions, lightweight zero-dependency core, and a query builder that prevents runtime errors by catching type mismatches at compile time. Unlike traditional ORMs, it focuses on type safety without sacrificing performance. It supports PostgreSQL and SQLite, with Community-provided drivers for MySQL and MSSQL.
npm install driftsqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to define a table schema, initialize a DriftSQL client, and execute a type-safe query with automatic parameter binding.
Migrate schema definitions to use defineTable with column builders.
Replace 'driver: 'pg'' with 'dialect: 'postgresql''.
Use sql`SELECT * FROM ${Users}` where Users is a table object from defineTable.Use import Drift from 'driftsql'.
Replace client.query(...) with client.execute(...).
Ensure moduleResolution is 'node16' or 'nodenext' in tsconfig.json, or set 'moduleResolution: 'bundler'. Also install latest version (>=2.0.0-beta).
Change import to import { sql } from 'driftsql'.Add dialect: 'postgresql' (or 'sqlite', etc.) to the DriftClient options.
No dependency data recorded yet.