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

umbot-knex-adapter

v1.0.0

Published

A robust Knex.js database adapter for the umbot TypeScript framework. Supports PostgreSQL, MySQL, SQLite, and MSSQL for building scalable Telegram and web bots.

Readme

umbot-knex-adapter

npm version npm downloads license umbot

A robust, type-safe Knex.js database adapter for the umbot framework.

umbot-knex-adapter seamlessly integrates Knex.js into your umbot application, allowing you to work with relational databases (PostgreSQL, MySQL, SQLite, MSSQL) using a clean, promise-based API without bloating the core framework with unnecessary SQL dependencies.

✨ Key Features

  • 🚀 Zero Core Bloat: SQL dependencies are isolated in this plugin.
  • 🗄️ Multi-DB Support: PostgreSQL, MySQL, MariaDB, SQLite, and MSSQL out of the box.
  • 🔒 Type-Safe: Fully written in TypeScript with strict typings.
  • 🔄 Connection Pooling: Built-in, configurable connection pooling for high-load bots.
  • 🛡️ Safe Queries: Prevents accidental mass UPDATE/DELETE operations.
  • 🤖 Umbot Native: Perfectly integrates with AppContext, BaseDbAdapter, and umbot skills.

📦 Installation

Install the adapter along with the knex query builder and your specific database driver:

# For PostgreSQL (Recommended)
npm install umbot umbot-knex-adapter knex pg

# For MySQL / MariaDB
npm install umbot umbot-knex-adapter knex mysql2

# For SQLite (Great for local dev or small bots)
npm install umbot umbot-knex-adapter knex better-sqlite3

🚀 Quick Start

Initialize the adapter and pass it to your umbot instance.

import { Bot } from 'umbot';
import { KnexAdapter } from 'umbot-knex-adapter';

const bot = new Bot();

// 1. Initialize the Database Adapter
const dbAdapter = new KnexAdapter({
    host: 'localhost',
    database: 'my_bot_db',
    user: 'postgres',
    pass: 'super_secret_password',
    options: {
        client: 'pg', // 'pg', 'mysql2', 'better-sqlite3', etc.
        port: 5432,
        pool: { min: 2, max: 10 },
        debug: false, // Set to true to log all SQL queries
    },
});

// 2. Register it in the bot
bot.use(dbAdapter);

⚙️ Configuration Options

The options object in the adapter config accepts standard Knex parameters:

| Parameter | Type | Default | Description | | ---------- | ------- | ------- | ------------------------------------------------------------ | | client | string | 'pg' | The database driver (pg, mysql2, better-sqlite3, mssql). | | port | number | Auto | Database port. Auto-detected based on the client if omitted. | | pool.min | number | 2 | Minimum number of connections in the pool. | | pool.max | number | 10 | Maximum number of connections in the pool. | | debug | boolean | false | If true, logs all executed SQL queries to the console. | | connection | object | {} | Any additional driver-specific connection parameters. |

🧠 Using in Skills / Handlers

Once registered, the Knex instance is available in your umbot skills via the AppContext:

import { Bot, AppContext } from 'umbot';
import { KnexAdapter } from 'umbot/knex';

const bot = new Bot();
bot.use(new KnexAdapter());

🧪 Development & Testing

If you want to contribute to the adapter:

git clone https://github.com/max36895/umbot-knex-adapter.git
cd umbot-knex-adapter
npm install
npm run build
npm test

🔗 Ecosystem

This package is part of the umbot ecosystem:

  • umbot - The core universal bot framework (Telegram, VK, web, etc.).
  • umbot-knex-adapter - SQL Database adapter (this package).

📄 License

MIT © Maxim-M