npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mailwoman/sqlite

v11.1.0

Published

The one way a Mailwoman SQLite connection is opened: a typed Kysely client over node:sqlite, plus the sealed-artifact lifecycle.

Readme

@mailwoman/sqlite

This package provides typed Kysely connections backed by Node.js SQLite and helpers for building and opening read-only database artifacts.

Public library. Install with npm install @mailwoman/sqlite.

Quick start

import { DatabaseClient } from "@mailwoman/sqlite/client"

interface ExampleDatabase {
	places: { id: number; name: string }
}

using db = DatabaseClient.temp<ExampleDatabase>()

await db.schema
	.createTable("places")
	.addColumn("id", "integer", (column) => column.primaryKey())
	.addColumn("name", "text", (column) => column.notNull())
	.execute()

await db.insertInto("places").values({ id: 1, name: "Paris" }).execute()
const place = await db.selectFrom("places").selectAll().where("id", "=", 1).executeTakeFirst()

console.log(place?.name) // "Paris"

DatabaseClient extends Kysely and owns one SQLite connection. Pass a file path to its constructor for a persistent database. DatabaseClient.temp() creates an in-memory database. The package requires Node.js ^24.22.1 || >=26.12.1.

Open a built artifact

Given an existing database with the example schema:

import { openBuiltClient } from "@mailwoman/sqlite/sealed"

using db = await openBuiltClient<ExampleDatabase>("/data/places.db")
const places = await db.selectFrom("places").selectAll().execute()

openBuiltClient opens read-only by default. Its { write: true } option checks the file's write permissions before opening it and rejects a sealed file with SealedArtifactError. A read-only open doesn't require that the file has already been sealed.

Use using even when the factory is asynchronous. The connection's Symbol.dispose closes synchronously. The inherited destroy() method is available when explicit asynchronous teardown is needed.

Build and replace databases

buildSealedArtifact(), exported from @mailwoman/sqlite/sealed/build, runs these stages:

  1. Create tables and ingest rows into a temporary file beside the destination.
  2. Run an optional batched ingest if the initial ingest returns null.
  3. Run the caller's finish callback for checks, indexes and metadata.
  4. Vacuum and close the database.
  5. Seal the temporary database and swap it into the destination.

sealDatabase() checkpoints the write-ahead log, switches journal mode and sets the file permissions to 0444. Close writers before sealing. Keep verification in the build's finish callback so it completes before the replacement becomes visible.

Query interfaces

Use Kysely's query and schema builders for typed queries and table definitions. exec() supports operations such as pragmas, vacuuming and virtual-table creation. prepare() exposes synchronous prepared statements on the same connection for bulk inserts and synchronous lookup interfaces. function() registers a SQLite function before statements that call it are prepared.

Additional subpaths provide batching, schema inspection, column helpers and the SQLiteLookup base class. See the exports and database conventions before adding a builder.

License

The package declares AGPL-3.0-only OR LicenseRef-Commercial.