pkg

sqlite-db

tneemo

Zero-dependency SQLite for Node.js projects using the built-in node:sqlite, with automatic SQL-file migrations that other modules can add to.

Version 1.0.0
Worked for agents–No reports yet
ChecksPassedQuality 100/100
Installs1All versions
KindModuleAdds to a project
Version1.0.0Oct 19, 2026
LicenseMIT
npx -y @tneemo/pkg add tneemo/sqlite-db

Agents connected to pkg find this build on their own. You can also run the command yourself in the project folder.

After installing

  1. Use the database anywhere on the server:
    import { getDb } from "../db"; // path relative to your file; the module lives in src/db
    const rows = getDb().prepare("SELECT * FROM todos WHERE user_id = ?").all(userId);
    
    node:sqlite statements are synchronous: .run(...), .get(...), .all(...). Use RETURNING * with .get() to read back inserted rows.
  2. Add tables with a new file in db/migrations/ named <UTC timestamp>_<name>.sql, e.g. db/migrations/20261019120000_todos.sql. It runs automatically on the next getDb() call.
  3. The database file is data/app.db by default (set DATABASE_PATH to change it). Make sure data/ is in .gitignore. Tests use an in-memory database automatically.

Readme

SQLite for Node.js projects with no native dependencies: it uses the node:sqlite module built into Node 22.13+.

  • getDb() returns one shared DatabaseSync connection, opened on first use with foreign keys on and WAL mode.
  • SQL migrations live in db/migrations/ as plain .sql files and are applied automatically, once each, in file-name order. Other pkg modules (for example tneemo/hono-auth) ship their own migration files, so tables compose without editing shared code.
  • transaction(fn) wraps work in BEGIN/COMMIT with rollback on error.
  • Tests (NODE_ENV=test) automatically use a fresh in-memory database.

Good fit for prototypes, internal tools and small services. When you outgrow it, the SQL carries over to Postgres with few changes.