DriftSQL

A lightweight, type-safe SQL client for TypeScript with support for PostgreSQL, MySQL, LibSQL/SQLite, and Neon.

main.ts
import { PostgresDriver, SQLClient } from 'driftsql'
import type { Database } from './db-types' // Generated types

const driver = new PostgresDriver({
  connectionString: 'postgresql://user:password@localhost:5432/mydb'
})

const client = new SQLClient<Database>({ driver })

// Type-safe queries with full IntelliSense
const user = await client.findFirst('users', { 
  email: 'john@example.com' 
}) // Returns Users | null

const posts = await client.findMany('posts', {
  where: { published: true },
  limit: 10
}) // Returns Posts[]

🔐 Type Safe

Full TypeScript support with generated interfaces from your database schema. Catch errors at compile time, not runtime.

🔄 Unified API

Same interface across PostgreSQL, MySQL, LibSQL/SQLite, and Neon. Switch databases without changing your code.

🚀 Modular

Import only what you need with built-in SQL injection protection. Lightweight and tree-shakeable.

🛡️ Secure

Parameterized queries by default protect against SQL injection. Built with security best practices.

⚡ Transactions

Full transaction support with automatic rollback on errors. Ensure data consistency across operations.

🔍 Schema Inspection

Automatically generate TypeScript interfaces from your database schema. Keep types in sync effortlessly.

Supports Your Favorite Databases

P

PostgreSQL

Full-featured with transactions

M

MySQL

Reliable with connection pooling

S

LibSQL/SQLite

Local & remote with Turso

N

Neon

Serverless PostgreSQL

Ready to Get Started?

$ bun add driftsql

Install DriftSQL and start building type-safe database applications in minutes.

Read the Documentation