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

drizzle-databend

v0.1.14

Published

A drizzle ORM driver for use with Databend. Based on drizzle's Postgres driver surface.

Downloads

3,437

Readme

drizzle-databend

A Drizzle ORM driver for Databend. Built on Drizzle's Postgres driver surface (pg-core) since Databend supports $1 positional parameters and double-quote identifier quoting.

Uses databend-driver (NAPI-RS bindings) as the underlying client.

Install

bun add drizzle-databend drizzle-orm databend-driver

Quick start

import { drizzle } from 'drizzle-databend';
import { pgTable, integer, varchar, text } from 'drizzle-orm/pg-core';
import { eq } from 'drizzle-orm';

const users = pgTable('users', {
  id: integer('id').notNull(),
  name: varchar('name', { length: 256 }).notNull(),
  email: text('email'),
});

const db = await drizzle('databend://databend:databend@localhost:8000/default?sslmode=disable');

// Insert
await db.insert(users).values({ id: 1, name: 'Alice', email: '[email protected]' });

// Select
const rows = await db.select().from(users).where(eq(users.name, 'Alice'));

Databend-specific column types

import { databendVariant, databendArray, databendTuple, databendMap, databendTimestamp, databendDate } from 'drizzle-databend';

const events = pgTable('events', {
  id: integer('id').notNull(),
  payload: databendVariant('payload'),         // VARIANT (semi-structured JSON)
  tags: databendArray('tags', 'VARCHAR'),       // ARRAY(VARCHAR)
  coords: databendTuple('coords', ['FLOAT', 'FLOAT']), // TUPLE(FLOAT, FLOAT)
  attrs: databendMap('attrs', 'VARCHAR', 'VARCHAR'),    // MAP(VARCHAR, VARCHAR)
  createdAt: databendTimestamp('created_at'),   // TIMESTAMP
  eventDate: databendDate('event_date'),        // DATE
});

Connection options

// DSN string (async, auto-pools with 4 connections)
const db = await drizzle('databend://user:pass@host:8000/db?sslmode=disable');

// With config
const db = await drizzle('databend://...', { pool: { size: 8 }, logger: true });

// Config object
const db = await drizzle({ connection: 'databend://...', schema: mySchema });

// Explicit client (sync, no pooling)
import { Client } from 'databend-driver';
const conn = await new Client('databend://...').getConn();
const db = drizzle({ client: conn });

// Disable pooling
const db = await drizzle('databend://...', { pool: false });

Transactions

await db.transaction(async (tx) => {
  await tx.insert(users).values({ id: 2, name: 'Bob', email: '[email protected]' });
  await tx.update(users).set({ name: 'Robert' }).where(eq(users.id, 2));
});

Note: Databend does not support savepoints. Nested transactions use a rollback-only fallback.

Migrations

import { migrate } from 'drizzle-databend';

await migrate(db, { migrationsFolder: './drizzle' });

Development

Prerequisites

You need a running Databend instance. The quickest way is Docker:

docker run -d \
    --name databend \
    --network host \
    -e MINIO_ENABLED=true \
    -e QUERY_DEFAULT_USER=databend \
    -e QUERY_DEFAULT_PASSWORD=databend \
    -v minio_data_dir:/var/lib/minio \
    --restart unless-stopped \
    datafuselabs/databend

See the Databend self-hosted quickstart for more options.

Verify the connection:

bendsql -udatabend -pdatabend

Commands

bun install           # Install dependencies
bun run build         # Build (dist/index.mjs + type declarations)
bun test              # Run integration tests (requires running Databend)

Seed data

Populate two sample tables (users and events) for manual testing:

bun run scripts/seed.ts

This creates 5 users and 10 events with VARIANT payloads and timestamps.

Architecture

Built on the same pattern as drizzle-duckdb:

  • driver.ts -- drizzle() factory and DatabendDatabase extending PgDatabase
  • session.ts -- DatabendSession and DatabendPreparedQuery for query execution
  • dialect.ts -- DatabendDialect extending PgDialect with Databend-specific migrations and type mapping
  • client.ts -- Low-level execution wrapping databend-driver's Connection API
  • pool.ts -- Connection pooling via Client.getConn()
  • columns.ts -- Custom column types (VARIANT, ARRAY, TUPLE, MAP, TIMESTAMP, DATE)
  • sql/result-mapper.ts -- Maps Databend results to Drizzle's expected format

License

MIT