Getting Started

db0 provides an easy way to connect and query sql database providers.


DB0 development is in the early stages. Followup progress via GitHub issues.

DB0 is a lightweight SQL connector:

✅ Works with several SQL connectors.

✅ Can be integrated with ORMs and embeded into frameworks.

✅ Provides a simple but elegant query API out of the box.

Quick start

Install db0 npm package:

npm i db0
import { createDatabase, sql } from "db0";
import sqlite from "db0/connectors/better-sqlite3";

// Initiate database with SQLite connector
const db = createDatabase(sqlite({}));

// Create users table
await db.sql`CREATE TABLE IF NOT EXISTS users ("id" TEXT PRIMARY KEY, "firstName" TEXT, "lastName" TEXT, "email" TEXT)`;

// Add a new user
const userId = "1001";
await db.sql`INSERT INTO users VALUES (${userId}, 'John', 'Doe', '')`;

// Query for users
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${userId}`;
console.log(rows);

Next steps

Read more in Connectors.
Read more in Integrations.